Configure Log4Net - checkmarx-ts/CxAnalytix GitHub Wiki

Log4Net Configuration

The Log4Net configuration file should be modified only to change the output path of the generated log files. It is an XML configuration where elements with the name "appender" with a "type" attribute set to the string "log4net.Appender.RollingFileAppender" contain the file path that determines where the logs are written.

The "file" element in each of the "appender" elements described above can be configured to place the logs in an absolute or a relative path. Modify the path portion of the output name to place the log in the desired location. Ensure all directories in the specified path are created.

In the following example XML snippet, the log is configured to be written to C:\temp\:


  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
    <filter type="log4net.Filter.LoggerMatchFilter">
      <acceptOnMatch value="false" />
      <loggerToMatch value="RECORD" />
    </filter>

    <file type="log4net.Util.PatternString" value="C:\temp\CxAnalytixService.%date{yyyy_MM_dd}.log" />
    <!--                                           ^^^^^^^^  ->
    <appendToFile value="true" />
    <maximumFileSize value="100MB" />
    <rollingStyle value="Size" />
    <staticLogFileName value="false" />
    <countDirection value="1" />

    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="[%date{yyyy-MM-ddTHH:mm:sszzz}][%5level][%thread][%logger] %message%newline" />
    </layout>
  </appender>

Refer to the default logging configuration file for examples of a correct logging configuration.

⚠️ **GitHub.com Fallback** ⚠️