Customizing log4j1 configuration by using differential extensibility

For differential extensibility, you need to add only the differential customizations in the custom log4j1 XML file.

About this task

To customize the log4j1 configuration by using differential extensibility, complete the following steps:

Procedure

  1. Create a custom log4jconfig.xml file in the <runtime_sandbox>/extensions/global/resources/deltalog4jconfig directory. The custom log4jconfig.xml file must be a valid XML file in the same format.
  2. In log4jconfig.xml file, add only the differential overrides and custom categories or appenders.
    Consider the following application-provided appended:
    <appender name="ALL" class="com.sterlingcommerce.woodstock.util.frame.logex.SCIAppender">
            <param name="rotateLogs" value="true" />
            <param name="maxLogSize" value="100000" />
            <param name="maxNumLogs" value="10" />
            <param name="file" value="/opt/OM/runtime/logs/sci${IBM_LOG_FILE}.log" />
            <layout class="com.sterlingcommerce.woodstock.util.frame.logex.SCICommonLayout">
                <param name="ConversionPatternRef" value="appender.ALL.pattern"/>
                <param name="DefaultConversionPattern" value="%d:%-7p:%t: %-60m [%X{AppUserId}]: [%X{TenantId}]: %-25c{1}%n"/>
            </layout>
            <filter class="com.sterlingcommerce.woodstock.util.frame.logex.SCICommonFilter" />
            <filter class="com.sterlingcommerce.woodstock.util.frame.logex.SCIPatternFilter" />
        </appender>
    To use differential extensibility for the application-provided appender, override the appender in the <runtime_sandbox>/extensions/global/resources/deltalog4jconfig/log4jconfig.xml file.
    <log4jconfigdelta>
       <appender name="ALL" >
            <param name="rotateLogs" value="false" />
            <param name="maxNumLogs" remove="true"/>
            <param name="file" value="/opt/SSFS_9.5/runtime/logs/sci${IBM_LOG_FILE}_custom.log" />
            <layout class="com.sterlingcommerce.woodstock.util.frame.logex.SCICommonLayout">
                <param name="ConversionPatternRef" value="appender.ALL.pattern"/>
                <param name="DefaultConversionPattern" value="%d:%-8p:%t: %-60m [%X{AppUserId}]: [%X{TenantId}]: %-25c{1}%n"/>
            </layout>
            <filter class="com.abcdcorp.CustomFilter" />
        </appender>
    </log4jconfigdelta>
    Note: Merging of elements is done only at the first level of child elements and not their children. Therefore, in the example, even if there is no change to the ConversionPatternRef parameter, the complete layout element be specified in the differential file.
    Consider the following application-provided category:
    <category  name="com.ibm" class="com.yantra.yfc.log.YFCLogCategory" additivity="false" >
            <level class="com.yantra.yfc.log.YFCLogLevel" value="WARN"  />
             <appender-ref ref="CONSOLE" />
            <appender-ref ref="ALL" />
        </category>
    To use differential extensibility for the application-provided category, override the category in the <runtime_sandbox>/extensions/global/resources/deltalog4jconfig/log4jconfig.xml file.
    <log4jconfigdelta>
       <category name="com.ibm">
            <appender-ref ref="CONSOLE" remove="true"/>
            <appender-ref ref="CUSTOM_APPENDER" />
        </category>
    </log4jconfigdelta>
    Tip: Do not override the yfs.log4j.configuration property in the customer_overrides.properties file.

What to do next

Build the resource extension by rebuilding the resources.jar.