How to capture verbose logging for AD Connect in a file

How to capture verbose logging for AD Connect in a file

Published: 12/29/2016
Problem:
The administrator of AD Connect wants to capture verbose logging in a file and want to keep the file size at the specified size.

Solution:
AD Connect uses a 3rd-party library called log4net.
By using log4net.Appender.RollingFileAppender it will overwrite the file contents when it reaches to the specified file size.

The below is an example:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
  <appender name="console" type="log4net.Appender.ConsoleAppender">
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%-5level - %message%newline" />
    </layout>
  </appender>

  <appender name="eventlog" type="com.pingidentity.adconnect.logger.CustomEventLogAppender" >
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %-5level - %message%newline" />
    </layout>
  </appender>
  
  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
   <file value="c:\tmp\roll.log" />
   <appendToFile value="true" />
   <rollingStyle value="Size" />
   <maxSizeRollBackups value="0" />
   <maximumFileSize value="100MB" />
   <staticLogFileName value="true" />
   <layout type="log4net.Layout.PatternLayout">
       <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
   </layout>
</appender>
  
  <root>
    <level value="ALL" />
    <appender-ref ref="console" />    
    <appender-ref ref="RollingFileAppender" />
  </root>

  <logger name="Topshelf">
    <level value="ALL" />
    <appender-ref ref="RollingFileAppender" />
  </logger>
</log4net>
In the example above most verbose level logs are written to c:\tmp\roll.log and the file contents will be overwritten when the size reaches to 100MB.
 
Category:
ADConnect ,