IBM Support

Advanced Logging with LOG4J in IBM Sterling B2B Integrator

Technical Blog Post


Abstract

Advanced Logging with LOG4J in IBM Sterling B2B Integrator

Body

IBM Sterling B2B Integrator (ISBI) is a product that has many components which are writing log messages to their corresponding log files. With the default logging built into ISBI the possibility to configure these logfiles is limited to a certain degree. Changing the behavior completely or even redirecting the logging is not available out of the box. But ISBI also offers another way of logging that is turned off by default.

Introducing LOG4J

ISBI has also the option to use the LOG4J framework if wanted. It can be enabled on per-logger basis. The LOG4J libraries and config files are already available in ISBI and just need to be configured. In the ISBI product we ship a sample configuration for the log4j properties as an XML file. Please be aware that this is still the 1.2 Version of LOG4J as of now. You are free to use the different appenders that are offered in the LOG4J framework. Please see an example below.

Disclaimer: Test first!

Since some of these changes can render your system unusable, please implement on your test system first. Pay special attention to those loggers that can write out a high number of lines per time unit. The performance of the LOG4J may be different to the builtin logger and should be tried first

Steps to enable LOG4J Logging

  • You have to point the ISBI logging framework to the log4j property XML file
  • You need to assign a new logclass to the logger that you would like to modify. For that purpose you specify a different Java Class
  • If neccessary you modify the LOG4J configuraition to suit your needs.

Real life example

In this real life example I'd like to show you how to point the system logger to LOG4J and use a different appender. For the sake of this example I'll use the "Daily Rolling Appender ". It will allow you to specify a "DatePattern". That pattern instructs the appender to create a new logfiles e.g. every day. In the example a new system logfile will be created every minute. For more configuration options in LOG4J, please refer to the Online Documentation

  • Point the ISBI system to the log4j configuration

    In "customer_overrides.properties" add a line that points to the log4j.properties.xml file

    
            logService.log4jConfigFile=<YOUR_INSTALL_DIR>/properties/log4j.properties.xml
            
  • Redirect the system logger from the internal logger to the LOG4J logger

    In "customer_overrides.properties" add a line that rewires the logger to the LOG4J class

    
            logService.systemlogger.logclass=com.sterlingcommerce.woodstock.util.frame.log.Log4jLogger
            
  • For this example we will change the default appender in LOG4J to another one that creates a new logfile every minute

    In your log4j.properties.xml file the systemlogger has a reference to the systemlogger_appender. Here is the example config for the systemlogger_appender. The DatePattern configured here will make sure that a new file would be generated every minute, if needed.

    
            <appender name="systemlogger_appender" class="org.apache.log4j.DailyRollingFileAppender">
                <param name="File" value="<YOUR_INSTALL_DIR>/logs/systeml4j.log" />
                <param name="DatePattern" value="'.'yyyy-MM-dd-HH-mm" />
                <layout class="org.apache.log4j.PatternLayout">
                    <param name="ConversionPattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] %p %m%n" />
                </layout>
            </appender>
            

References

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SS3JSW","label":"IBM Sterling B2B Integrator"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

UID

ibm11121619