Configure log4net Appenders for Central Logging
This article explains how to set up the log4net appenders for Quali Server and each Execution Server (New Job Scheduling logs are managed via FileBeat and configured separately). The log4net appenders define where to send the json logs collected by FileBeat as well as the log retention policy.
There are two log4net configuration files, one for Quali Server and another for each execution server. Starting with 2021.2, example log4net files with the new json appenders are included alongside the existing log4net.config files in the Quali Server and Execution Server installation directories. You may use these example files as is. However, if you are using customized log4net.config files, you may wish to copy the relevant sections from the example files into the log4net files, as explained in Configuring the json appenders on the existing log4net files below.
The example files are:
log4net.config.json.exampleapplies to Quali Server. Resides in the Quali Server installation directory (By default:C:\Program Files (x86)\QualiSystems\CloudShell\Server\)QsExecutionServer.exe.config.jsonlogs.exampleapplies to Execution Servers. Resides in the Execution server installation directory on each execution server (By default:C:\Program Files (x86)\QualiSystems\TestShell\ExecutionServer)
Using the example log4net files
The example log4net files are already configured properly and do not require any modifications. Feel free to use them if your log4net.config files have little to no customizations.
To use the example log4net files:
- On the Quali Server machine, do the following
- Open the
\CloudShell\Serverinstallation directory. - Backup the existing
log4net.configfile by renaming it to "log4net.config-org". - On the Quali Server machine, rename
log4net.config.json.exampleto "log4net.config". - Update the new
log4net.configfile with any required customizations from thelog4net.config-orgfile. - Restart Quali Server service.
- Open the
- On each Execution Server machine, do the following:
- Open the
\TestShell\ExecutionServerinstallation directory. - Backup the existing
QsExecutionServer.exe.configfile by renaming it to "QsExecutionServer.exe.config-org". - Rename
QsExecutionServer.exe.config.jsonlogs.exampleto "QsExecutionServer.exe.config". - Update the new
QsExecutionServer.exe.configfile with any required customizations from theQsExecutionServer.exe.config-orgfile. - Restart TestShell Execution Server service.
- Open the
Configuring the json appenders on the existing log4net files
If your log4net.config files are heavily customized, it may be easier to update them with the json appenders and loggers from the example files. Perform the below procedure for Quali Server and each Execution Server in CloudShell.
To configure log4net appenders:
-
Edit the
log4net.config.json.examplefile.The file includes several appender sections, one for each json log.
For example, appender section for the
TeamServer.Servicelog.<appender name="RollingJsonFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="JsonLogs\TeamServer.Service.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="1000KB" />
<staticLogFileName value="true" />
<layout type="QualiSystems.Infrastructure.Common.Logging.Log4Net.JsonQsLogLayout, QualiSystems.Infrastructure.Common">
<appname>QS</appname>
</layout>
</appender> -
Copy the relevant appender sections into the existing
log4net.configfile in the relevant CloudShell installation directory (CloudShell\Server or TestShell\ExecutionServer).tipFor each appender, you can define the retention policy for the log data using the appender's maxSizeRollBackups and maximumFileSize parameters. maxSizeRollBackups defines the maximum number of json files to keep for this log (By default: 10) and maximumFileSize defines the maximum size for each json file (1000 KB). Once all logs are fully populated, log4net replaces the oldest log file with a new one containing new data and then the second oldest and so on.
-
Next, declare the JSON appenders in the loggers.
For example, declaring RollingJsonFileAppenders ref in the root element:
<appender-ref ref="RollingJsonFileAppender" />For example:
<root>
<level value="WARN" />
<appender-ref ref="RollingFileAppender" />
<appender-ref ref="RollingJsonFileAppender" />
</root> -
Save the file.
-
Restart the appropriate service - Quali Server or TestShell Execution Server.
-
Repeat these steps for the
QsExecutionServer.exe.jsonlogs.examplefile.