Previous Topic: Complete the PrerequisitesNext Topic: Update the Threshold Parameter in Default Console Appender


Customize the Configuration File

You must customize the appender section of the log4j.xml file depending on your requirement, based on the parameters in the log4j file.

Follow these steps:

  1. Open the log4j.xml file from Installed_Loc/view/conf/ and modify the parameters for in-memory appender. The following code sample shows the in-memory appender parameters:
    <appender name="memory" class="com.ca.usm.util.log.MemoryAppender">
        <param name="File" value="${usm.home}/logs/error.log" />
        <param name="MaxFileSize" value="10MB" />
        <param name="MaxBackupIndex" value="10" />
        <param name="MaxMemoryLogs" value="50000" />     
        <param name="MaxMemoryTime" value="600000" /> 
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d{yyyy/MM/dd HH.mm.ss.SSS} %-5p [%X{UNIQUEID}] [%t] [%c{1}] %m%n" />
        </layout>
      </appender>
    

    You can customize the following parameters in appender section:

    File

    Defines the path of the file where the in-memory logs are logged in case of an error. The default is error.log

    Default: <param name="File" value="${usm.home}/logs/error.log" />

    MaxFileSize

    Defines the maximum size of the log file. Once the log file reaches the maximum size, the backup of the current log file is taken.

    Default: <param name="MaxFileSize" value="10MB" />

    MaxBackupIndex

    Defines the maximum number of backup files to be restored on the system.

    Default: <param name="MaxBackupIndex" value="10" />

    MaxMemoryLogs

    Defines the maximum count of logs in the memory, after which the appender either recycles the logs in memory, or moves them to temporary files on disk.

    The following actions are performed on the temporary files:

    • If there is no error, the temporary files are discarded
    • If there is an error, the logs in the temporary files are logged to the log file.

      The optimal value is tested to be 50000.

    Default: <param name="MaxMemoryLogs" value="50000" />

    MaxMemoryTime

    Defines the maximum time in milliseconds for the logs that remain in memory. If the logs remain in memory for MaxMemoryTime, they are discarded. The optimal value is tested to be 600000 milliseconds.

    Default: <param name="MaxMemoryTime" value="600000" />

    ConversionPattern

    Defines the log statements that are logged based on the pattern provided. For more details on the ConversionPattern, please refer to Apache log4j documentation.

    The {UNIQUEID} helps to identify the complete request from the beginning till the end of the request.

    <layout class="org.apache.log4j.PatternLayout">

    <param name="ConversionPattern" value="%d{yyyy/MM/dd HH.mm.ss.SSS} %-5p [%X{UNIQUEID}] [%t] [%c{1}] %m%n" />

    </layout>

    Important! Do not update the logger name parameter of the logger section in the log4j.xml configuration file.

  2. Save the file.

    You have customized the configuration file.