It seems like your browser didn't download the required fonts. Please revise your security settings and try again.
Barracuda RMM
formerly Managed Workplace

MWExpertSystem advanced logging configuration

  • Last updated on

All managed workplace products use a 3rd party Log4Net library for logging purposes. The logging configuration for most Managed Workplace components can be modified in the application config files. This document will focus on MWExpertSystem, and thus the MWExpertSystem.exe.config. This configuration is contained in the log4net XML node in the config file.

This example has been trimmed down, but the most basic configuration will appear as follows. There is a log file appender, and a logger. In this case, the logger node is named root because it is the default logger. Note the appender name is referenced in both as it's declared in the appender, and referenced in the logger

 

<log4net>
<!-- Define some output appenders -->
 <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="..\Logs\%property{LogName}.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{yyyy/MM/dd HH:mm:ss} [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="RollingFileAppender" />
</root>
</log4net>

 


The simplest change that can be made to the log file configuration relates to the number of logs that will be kept, and the maximum size of the log files. The defaults are to keep 5 logs, at a size of 5MB

 

<maxSizeRollBackups value="5" />
<maximumFileSize value="5MB" />

 

You can change the "level value" of the logger from INFO to DEBUG if you require additional logging, however this can impact performance as well as generate a lot of extra log detail making it more different to focus on what you're looking for. Rather than enable DEBUG logging for the entire application, you can add a logger for only that specific area of the application code. We'll use Automation in the following examples.

The TraceExpertSystem.txt log will show automation details such as the following

2015/04/16 21:00:00 [228] INFO Avg.MW.OM.MWExpertSystem.Business.Automation.AutomationTask - TaskCallback: Time to run Task a5ef88e2-4aee-422a-bfc5-d019cbb4befc.
2015/04/16 21:00:09 [119] INFO Avg.MW.OM.MWExpertSystem.Business.Automation.AutomationTaskManager - CheckDeviceTasks: File download and unzip of Task(a5ef88e2-4aee-422a-bfc5-d019cbb4befc) succeeded.
2015/04/16 21:00:09 [119] INFO Avg.MW.OM.MWExpertSystem.Business.Automation.AutomationTaskManager - CheckDeviceTasks: File download and unzip of Task(a5ef88e2-4aee-422a-bfc5-d019cbb4befc) succeeded.
2015/04/16 21:00:19 [160] INFO Avg.MW.OM.MWExpertSystem.Business.Automation.AutomationTaskManager - SubmitTaskData: 10.66.1.8: AutomatedTaskExecution:


The above log entries all share Avg.MW.OM.MWExpertSystem.Business.Automation. This is the name space in the applications code where these log messages stem from. To add DEBUG logging only for Automation, add the following logger to the MWExpertSystem.exe.config:

 

<logger name="Avg.MW.OM.MWExpertSystem.Business.Automation">
<level value="DEBUG"/>
<appender-ref ref="RollingFileAppender" />
</logger>

 

Continuing with the above example, you can also add an entirely separate appender to log DEBUG information related to automation into a new log file.

 

<appender name="AutomatedTaskFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="../Logs/TraceExpertSystem_AutomatedTask.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{yyyy/MM/dd HH:mm:ss} [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<logger name="Avg.MW.OM.MWExpertSystem.Business.Automation">
<level value="INFO"/>
<appender-ref ref="AutomatedTaskFileAppender" />
</logger>

 

When logging specific areas to separate logs however, the information will continue to be written to the root logger unless you add a filter to it. See below for a complete example including normal logging, and DEBUG logging of automation to a separate log file;

<log4net>
<!-- Define some output appenders -->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="..\Logs\%property{LogName}.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{yyyy/MM/dd HH:mm:ss} [%thread] %-5level %logger - %message%newline" />
</layout>
<filter type="log4net.Filter.LoggerMatchFilter">
<loggerToMatch value="Avg.MW.OM.MWExpertSystem.Business.Automation" />
<acceptOnMatch value="false" />
</filter>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="RollingFileAppender" />
</root>
<appender name="AutomatedTaskFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="../Logs/TraceExpertSystem_AutomatedTask.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="5" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{yyyy/MM/dd HH:mm:ss} [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<logger name="Avg.MW.OM.MWExpertSystem.Business.Automation">
<level value="DEBUG"/>
<appender-ref ref="AutomatedTaskFileAppender" />
</logger>
</log4net>

 

Additional Information

MWExpertSystem has an SC CONTROL command that will print all available logger instances to the TraceExpertSystem.txt log which you can then use to enable debug logging for specific classes.

Reference: MWExpertSystem control commands

Attachments
  • MWExpertSystem_Log4Net_SplitLogs.txt provides a complete log4net configuration section for MWExpertSystem which splits the following areas into separate log files to be used as an example.
    • Automation
    • Discovery
    • Integrated AV
    • Windows Event Collection