Logging

powerGate uses Apache log4net as core logging library, and additionally PostSharp Diagnostics for extended Debug logging.\

By default, all the logs are stored in a logfile located in ‘C:\Users\{USER}\AppData\Local\coolOrange\powerGate\Logs\powerGate.log’ and it contains only Warnings and Errors.
Perhaps you can find backups of previous logfiles in this directory.

The log4net settings file is located in C:\Program Files\coolOrange\Modules\powerGate\powerGate.log4net.
Further information about log4Net Configurations can be found here.

Log requests and responses

PowerGate has the opportunity to customize the format of the traced requests that are send to the server, and the received responses.

Log Level

powerGate has a special logging level called TRAFFIC. In this level all requests and responses will be logged. The level is located in the order between DEBUG and INFO, but you can even adjust this by changing the value ‘30001’ in these lines:

1
2
3
4
<level>
	<name value="TRAFFIC" />
	<value value="30001" />
</level>

In the following link you will find the default log levels associated with the numeric values they have at the bottom: Level.cs

If you want to change the logging level for all appenders e.g. to “TRAFFIC”, please visit the root logger and change the level in the lines:

1
<level value="TRAFFIC" />

you can configure the required logging level. You could set the level to “DEBUG”, than all the levels above Debug and also Debug will be logged.

Note

When increasing the loglevel for the root logger, please make sure your favorite appenders minlevel is configured to allow logging messages with the specified level.

When to change the logging behavior?

When you have issues or when you want to get a more detailed knowledge about what powerGate is doing, you can increase the logging level.

Note

When changing the loglevel to DEBUG PostSharp Diagnostics will be enabled and will log all the function calls into the log files. This could cause performance issues

Additionally you can change the logfile location or integrate the logging mechanism into your administrative environment by using build in EventLogMessages etc.

TrafficPatternLayout

Each appender has its own layout that defines how the log-messages are formatted. By using the special Layout powerGate.Erp.Client.Traffic.TrafficPatternLayout you have the possibility to configure two new ConverstionPatterns: RequestConversionPattern, ResponseConversionPattern.

The TrafficPatternLayout has all the functionality of a simple PatternLayout too. That means all logs that are not Requests or Responses can be configured by using the default ConversionPattern node.
Therefore all the available conversion pattern names from PatternLayout are available for the TrafficPatternLayout too.

RequestConversionPattern

This pattern applies when a request gets logged and additionally you have access to following options:

1
2
3
4
5
6
%Request{Protocol}
%Request{ProtocolVersion}
%Request{Method}
%Request{Url}
%Request{Headers}
%Request{Body}

For instance you are able to log something like this:

1
<RequestConversionPattern value="Called: %Request{Method}% on %Request{Url}" />

This will result in logs like:
Called: GET on localhost:8080/pgs/ERP/MaterialService/Materials

ResponseConversionPattern

This pattern applies when a response gets logged and additionally you have access to following options:

1
2
3
4
5
6
%Response{Protocol}
%Response{ProtocolVersion}
%Response{StatusCode}
%Response{Status}
%Response{Headers}
%Response{Body}

For instance you are able to log something like this:

1
<ResponseConversionPattern value="Received: %Response{StatusCode}% %Response{Status}" />

This will result in logs like:
Received: 200 OK

LogFile

You can see, that there are multiple logging-Appenders used. If you want to change the logging level in the logfile, please visit following appender:

1
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">

In the lines

1
2
3
4
<filter type="log4net.Filter.LevelRangeFilter">
	<levelMin value="WARN" />
	<levelMax value="FATAL" />
</filter>

you can configure the logginglevel. You could set the minimal filter level to “DEBUG”, than all the levels between the range Debug and Fatal will be logged.

In the line

1
<param name="File" value="${LOCALAPPDATA}\coolOrange\powerGate\Logs\powerGate.log" />

you can configure the outputpath and name of the logfile.

PowerShell IDE

PowerShell IDE’s like PowerShell console (and PowerShell ISE) are configured to show the logging levels in a different color.

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<mapping>
	<level value="DEBUG" />
	<foreColor value="Black" />
	<backColor value="White" />
</mapping>
<mapping>
	<level value="TRAFFIC" />
	<foreColor value="Black" />
	<backColor value="White" />
</mapping>
<mapping>
	<level value="INFO" />
	<backColor value="DarkGreen" />
</mapping>
<mapping>
	<level value="WARN" />
	<backColor value="DarkYellow" />
</mapping>
<mapping>
	<level value="ERROR" />
	<backColor value="Red" />
</mapping>
<mapping>
	<level value="FATAL" />
	<backColor value="DarkRed" />
</mapping>

These and many other options can be configured in the appender named ColoredConsoleAppender.