Logging

powerLoad (bcpToolkit) tools use 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\bcpToolkit\Logs\bcpToolkit.log’ and it contains Infos, 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\bcpToolkit\bcpToolkit.log4net.
Further information about log4Net Configurations can be found here.

You can change the logging behaviour of:

When to change the logging behavior?

When you have issues or when you want to get a more detailed knowledge about what went wrong, you can increase the loglevel.

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.

Following section is used to control the logging behaviour for all tools:

63
64
65
<root>
...
</root>

For the moment only following LogAppender is used:

LogFile

This is the main LogAppender used in all the loggers. If you want to change the logging level in the logfile, please visit following appender:

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

In the line

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

you can configure the outputpath and name of the logfile.

Since this appender has no configured LevelRangeFilter, its loggingLevel has to be configured on the loggers.
In the lines

63
64
65
66
<root>
	<level value="INFO" />
	<appender-ref ref="FileAppender" />
</root>

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

bcpViewer

Following section is used to control the logging behaviour for the bcpViewer.exe and it’s engine logic:

68
<logger name="bcpViewer"></logger>

In order to configure sub-functionalities like the UserInterface, the following configuration section could be used:

70
<logger name="bcpViewer.UI"></logger>

This is the place where you want to increase the logging level when you need more detailed informations about whats happening in the bcpViewer Database.

72
<logger name="bcpViewer.Database"></logger>

For all this sections, only the LogFile appender is used.

PowerShell IDE

When using bcpToolkit cmdlets in PowerShell environments, logs are written to the PowerShell Console Window.
Following section is used to control the logging behaviour for the Cmdlets of this module:

80
<logger name="bcpToolkit.Cmdlets"> ... </logger>

In order to customize the logging level in the console window, visit following appender that is used in addition to the LogFile.

ColoredConsoleAppender

ColoredConsoleAppenders are working for PowerShell IDE’s that support console windows.

23
<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">

In the lines

50
51
52
53
<filter type="log4net.Filter.LevelRangeFilter">
	<levelMin value="INFO" />
	<levelMax value="FATAL" />
</filter>

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

We are using a ColoredConsoleAppender, therefore you could also change the colors of the messages, depending on their log level:

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<mapping>
	<level value="DEBUG" />
	<backColor value="White" />
</mapping>
<mapping>
	<level value="INFO" />
	<backColor value="Green" />
</mapping>
<mapping>
	<level value="WARN" />
	<backColor value="Yellow" />
</mapping>
<mapping>
	<level value="ERROR" />
	<backColor value="Red" />
</mapping>
<mapping>
	<level value="FATAL" />
	<backColor value="Red, HighIntensity" />
</mapping>

Troubleshooting

The PowerShell ISE currently does not support console logs at all.

In addition to the earlier described logging section ‘bcpToolkit.Cmdlets’, following section can be adjusted for PowerShell environments as well, since they make use of the .NET library internally.

Projects using .NET Library

When using the bcpDevKit .NET library in custom projects, logging can be controlled in following section:

75
<logger name="bcpDevKit"> ... </logger>

In addition to the LogFile, all projects that support console windows will make use of the configuration for the ColoredConsoleAppender too.
For debugging purpose, following additional appender can be adjusted in order to meet your projects requirements:

OutputDebugStringAppender

The OutputDebugStringAppender writes to the OutputDebugString system.

56
57
58
59
60
<appender name="OutputDebugStringAppender" type="log4net.Appender.OutputDebugStringAppender" >
	<layout type="log4net.Layout.PatternLayout">
	        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
	</layout>
</appender>

When developing new projects this can be useful because the logs are directly shown in the Visual Studio Output Window.