CEPM Dotnet Agent Guide V3.3.1.0
Configuring the log.config File

Table Of Contents

Configuring log.config File


Configuring log.config File


This appendix describes the structure of PEP log configuration file (log.config) and guides you through the procedures of configuring it.

The following is a sample log.config file.

<configuration>
    <configSections>
	      <section name="log4net" 
 	               type="System.Configuration.IgnoreSectionHandler" />
    </configSections>
    <log4net>
         <appender name="RollingLogFileAppender"    
                   type="log4net.Appender.RollingFileAppender">
 	           <param name="File" value="DotnetAgent.log" />
	           <param name="AppendToFile" value="true" />
 	           <param name="MaxSizeRollBackups" value="10" />
	           <param name="MaximumFileSize" value="10MB" />
	           <param name="RollingStyle" value="Size" />
	           <param name="StaticLogFileName" value="true" />

              <layout type="log4net.Layout.PatternLayout">
                  <param name="Header" value="\r\n\r\n------------\r\n" />
                  <param name="Footer" value="\r\n-----------------\r\n\r\n" />
                  <param name="ConversionPattern" value="%d [%t] %-5p -%m%n" />
              </layout>
         </appender>
         <appender name="ColoredConsoleAppender"            
                  type="log4net.Appender.ColoredConsoleAppender">
              <mapping>
	              <level value="ERROR" />
	              <foreColor value="White" />
	              <backColor value="Red" />
              </mapping>
              <mapping>
 	              <level value="DEBUG" />
      	        <backColor value="Green" />
              </mapping>
              <mapping>
                 <level value="INFO" />
	              <foreColor value="White" />
              </mapping>
              <layout type="log4net.Layout.PatternLayout">
                   <param name="ConversionPattern" value="%-5p: %m%n" />
              </layout>
         </appender>
         <root>
             <level value="ALL" />
	          <appender-ref ref="RollingLogFileAppender" />
	          <appender-ref ref="ColoredConsoleAppender" />
         </root>
   </log4net>
</configuration>

The following are the general configurations that can be made in the log.config file.

1. Updating the File Appender

Change the name of the log file (named as DotnetAgent.log in the sample file), update the Name parameter in the <Appender> tag.

Change the maximum file size for back up, update the MaximumFileSize parameter with the required value. This enables the application to create back up on exceeding the specified size.

Change the header and footer style of the log file, update the Header and Footer parameters in the <layout> tag.

2. Updating the Console Appender

Change the colors of individual log levels, update the corresponding <mapping> tags available for different log levels.

3. Updating the Root

Update the <Root> tag to specify which appender to be available in the log file. If you want to view both appenders, keep this tag unchanged. If you want to keep only one appender, uncomment the other parameters. For example, if you want to keep only the File appender then comment the Console Appender and if you want to keep only the Console appender then comment the File Appender.