When TDI is installed, a FileAppender is used for the
default logger. If we want to change the default logger
change the content of the log4j.properties file
situated in the TDI_installdir/etc folder.
The default configuration is as follows:
The FileAppender logger truncates the content of the ibmdi.log file (situated in TDI_installdir/logs) each
time the TDI server is started. If want to change that behavior you
must change the log4j.appender.Default.append property to
true.
In the log4j.properties file we can find also two examples for
changing the default logger to RollingFileAppender or DailyRollingFileAppender.
If we want to use them just uncomment the preferred one and comment
the FileAppender logger:
These are some of the parameters you find in the file Log4J.properties
(for ibmdisrv and ibmditk).
Full documentation can be found at http://jakarta.apache.org/log4j/docs.
We can use this framework to differentiate how the different AssemblyLines log.
This information is intended for users who want to
continue using the global.properties file
to customize logging output. We can customize logging output through
the Configuration Editor (ibmditk).
The following section defines a log scheme called CONSOLE, which
later can be used by specific AssemblyLines:
Now
in order to have the AssemblyLines myAL use
this, we need the lines:
Refer
to the full Log4J (version 1.2) documentation for description of the
ConversionPattern parameters. Here are some parameters:
this is typically in the form Type.alName.xxx. Type can
be EventHandler or AssemblyLine, alName is
the name of the AssemblyLine (or EventHandler as named by the creator), and xxx is a unique ID for the thread. %c{2} outputs alName & unique
ID.
# This is the default logger, we will see that it logs to ibmdi.log
log4j.appender.Default=org.apache.log4j.FileAppender
log4j.appender.Default.file=logs/ibmdi.log
log4j.appender.Default.layout=org.apache.log4j.PatternLayout
log4j.appender.Default.layout.ConversionPattern=%d{ISO8601} %-5p [%c] - %m%n
log4j.appender.Default.append=false
##########ROLLING FILE SIZE APPENDER
##RollingFileAppender rolls over log files when they reach a certain size specified by the
##MaxFileSize parameter
#log4j.appender.Default=org.apache.log4j.RollingFileAppender
#log4j.appender.Default.File=logs/ibmdi.log
#log4j.appender.Default.Append=true
#log4j.appender.Default.MaxFileSize=10MB
#log4j.appender.Default.MaxBackupIndex=10
#log4j.appender.Default.layout=org.apache.log4j.PatternLayout
#log4j.appender.Default.layout.ConversionPattern=%d{ISO8601} %-5p [%c] - %m%n
##########DAILY OUTPUT LOG4J SETTINGS
## With the DailyRollingFileAppender the underlying file is rolled over at a user chosen frequency.
##The rolling schedule is specified by the DatePattern option
#log4j.appender.Default=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.Default.file=logs/ibmdi.log
#log4j.appender.Default.DatePattern='.'yyyy-MM-dd
#log4j.appender.Default.layout=org.apache.log4j.PatternLayout
#log4j.appender.Default.layout.ConversionPattern=%d{ISO8601} %-5p [%c] - %m%n
Creating our own log strategies
Log4J.appender.CONSOLE=org.apache.Log4J.ConsoleAppender
Log4J.appender.CONSOLE.layout=org.apache.Log4J.PatternLayout
Log4J.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p - %m%n0
Log4J.logger.AssemblyLine.myAL=INFO, CONSOLE