Configuring Logging for the eG Agent Communicating with the eG RUM Collector

As already mentioned, the logger creates a rum.log file in the <eg_agent_install_dir>\agent\logs directory (on Windows; on Unix, this will be the /opt/egurkha/agent/logs directory) to track the eG remote agent’s communication with the eG RUM collector.

Like the collector-related logs discussed in Configuring Logging for the eG RUM Collector section, you can configure the properties of the logging activity of the rum.log as well. For this purpose, eG provides a eg_logback.xml file. This file is available in the <EG_AGENT_INSTALL_DIR>\lib directory (on Windows; on Unix, this will be the opt/egurkha/lib directory). The contents of this XML file are as follows:

<?xml version="1.0"?>
<configuration scanPeriod="5 seconds" scan="true">
<appender class="com.eg.ch.qos.logback.core.rolling.RollingFileAppender" name="RUMLOGGER">
<file>${egurkhaInstallDir}/agent/logs/rum.log</file>
<rollingPolicy class="com.eg.ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${egurkhaInstallDir}/agent/logs/rum%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>20</maxIndex>
</rollingPolicy>
<triggeringPolicy class="com.eg.ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>20MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%date{dd/MM/yyyy HH:mm:ss} %level - %msg%n</pattern>
</encoder>
</appender>
<logger name="RUMLOGGER" additivity="true" level="DEBUG">
<appender-ref ref="RUMLOGGER"/>
</logger>
</configuration>

The lines/tags in Bold in the above extract are the ones that govern how logging is performed by the rum.log. Let’s take a look at these Bold entries, in random order.

Typically, the rum.log can be configured with one of the following log levels: ALL or TRACE, DEBUG, INFO, WARN, ERROR. Each of these log levels and their significance has been discussed below:

  • ALL or TRACE: Setting the log level to ALL or TRACE enables the logger to log detailed information pertaining to the events logged. Moreover, once the log level is set to ALL or TRACE, then DEBUG, INFO, WARN, and ERROR messages will also be logged in the log files.
  • DEBUG: Set the log level to DEBUG to make sure that DEBUG messages are logged in the log file. Using such messages, you can easily troubleshoot issues related to the eG agent-collector communication. Once the log level is set to DEBUG, then, INFO, WARN, and ERROR messages will also be logged in the log files. However, detailed event information provided by the ALL or TRACE level will not be available for the DEBUG level.
  • INFO: To capture general information messages, set the log level to INFO. In this case, besides INFO messages, WARN and ERROR messages will also be logged in the log files.
  • ERROR: By setting the log level to ERROR, you can make sure that only error messages are captured by the log files.

By default, the rum.log is configured with the DEBUG log level. This is why, the level parameter in the line that begins with <logger name="RUMLOGGER" additivity="true". . .>is set to “DEBUG” by default. Depending upon the types of events you want captured and the level of information you want logged in the log file, you can change the value of the level parameter to any of the levels described above.

Besides the log level, you can also configure log rolling using the eg_logback.xml file. By configuring a size (in MB) within the <maxFileSize></maxFileSize> XML tags, you can indicate the maximum size up to which the rum.log can grow. Beyond that point, all entries from the log file will be automatically copied to a new log file, and all subsequent messages will be logged in the old log file. By default, 20  MB is the maximum size up to which the rum.log can grow. This can be increased or decreased according to the logging needs of your environment. If you go with the default setting for instance, messages will be logged in the rum.log file (for example), only until the file becomes 20 MB in size. After this point, a new log file named rum1.log (by default) will be created, to which all entries from the rum.log log will be copied. This default naming convention can also be overridden by editing the value contained within the <fileNamePattern></fileNamePattern> tags. The default value within these tags is as follows:

${egurkhaInstallDir}/agent/logs/rum%i.log

Here, {egurkhaInstallDir}/agent/logs indicates the default destination for the rum.log file, and the rum%i.log indicates the pattern using which the additional rum.log files created in the default destination are to be named. The %i  in the rum%i.log pattern, represents an integer which will be incremented for every additional log file that is created. Going by this default pattern, once the size of the rum.log file violates its <maxFileSize></maxFileSize> threshold, the next log file that is created will be named rum1.log, the one after that will be named rum2.log and so on.

In this manner, a maximum of 20 log files will be created by default. This is governed by the <maxIndex></maxIndex> tags in the eg_logback.xml file. By default, the value contained within these tags is 20. You can increase or decrease this value to suit your needs.

You can also configure the format in which events are to be logged in the rum.log using the <pattern></pattern> tags. By default, the following pattern is configured within these tags:

%date{dd/MM/yyyy HH:mm:ss} %level - %msg%n

Here, %date{dd/MM/yyyy HH:mm:ss} refers to the date/time of the event. %level indicates the log level. %msg refers to the message.

You can change the log file pattern to remove or reposition any of the variables mentioned above.

A sample log file output is provided below:

2015-08-17 18:23:01,496 DEBUG - [To_Test][RUMDeviceTest] IS STARTING !!!

Here:

2015-08-17 18:23:01,496 is the date/time of the event.

DEBUG is the log level

[To_Test][RUMDeviceTest] IS STARTING !!!is the message

If required, you can remove one/more of these variables from the pattern specification or add more variables to it. The variables that can be added are as follows:

  • %C, to include the class name in the log entry
  • %M, to include the method name
  • %L, to include the line number

For instance, your log file pattern can be as follows:

%date{dd/MM/yyyy HH:mm:ss} %level {%C %M} – [%L] - %msg%n

In this case, your log entry will be as follows:

2015-08-17 18:23:01,496 DEBUG {RUMDeviceTest computeMeasures} - [30] - [To_Test][RUMDeviceTest] IS STARTING !!!

Here:

2015-08-17 18:23:01,496 is the date/time of the event.

DEBUG is the log level

RUMDeviceTest is the class name

computeMeasures is the method name

30 is the line number

[To_Test][RUMDeviceTest] IS STARTING !!!  is the message