The plug-in uses a single configuration file to set up the logging environment. This file is installed in the root directory for your plug-in and contains a few lines of global configuration followed by a configuration section for each appender. (Note that this discussion of updating configuration entries pertains to your own plug-in; do not make changes to the supplied configuration file for Unisys plug-ins.)
For the examples in this topic, we are using three appenders, A1, A2, and A3. Appender A1 is a rotating file appender, A2 is an Eclipse Log appender, and A3 is an NT Event Log appender.
log4j.rootLogger=,A3
log4j.logger.com.unisys.os2200=,A1,A2,A3
The rootLogger entry is required to determine if any logger is enabled by default. The logger entry gives the name by which this logger will be referenced throughout your code. Leading commas are required.
With this configuration, you can specify the size of your log file, how many log cycles are to be retained, the name of the log file, the data to be placed in the file, and the level at which the log operates. When the log file reaches MaxFileSize, the log is closed and a new file is started. When the number of log files reaches MaxBackupIndex, the oldest log file is overwritten.
By default, the maximum file size (MaxFileSize) is set to 5 MB and number of backup files (MaxBackupIndex) is set to 10. Therefore, the logger creates a maximum of 10 backup files when the log file reaches 5 MB.
log4j.appender.A1=com.unisys.logging.core.PluginFileAppender
log4j.appender.A1.MaxFileSize=5MB
log4j.appender.A1.MaxBackupIndex=10
log4j.appender.A1.File=/unisys-plugin.log
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d:%p:%C{3}:%F:%L:%M:%t:%x :%m %n
log4j.appender.A1.threshold=DEBUG
The File parameter specifies the name of the file. The plug-in writes the log file into the metadata space in the run-time workspace for the plug-in that defines the logger. For example, if the defining class is my.root.plugin and your Eclipse workspace directory is C:\eclipse-workspace, the log files reside in <EclipseInstallDir>\plugins\com.unisys.tde.core_<version>\logger.properties
The threshold parameter specifies the level at which the logger operates.
The ConversionPattern parameter specifies the data to be written to the file. The format of data defined by the ConversionPattern parameter matches the format expected by the Chainsaw log viewing application, so do not change the format unless you make a corresponding change in the Chainsaw viewer’s configuration.
log4j.appender.A2=com.unisys.logging.core.PluginLogAppender
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d|%l|%p|%t|%x|%m%n
log4j.appender.A2.threshold=ERROR
You may change only the ConversionPattern and threshold parameters.
log4j.appender.A3=com.unisys.logging.core.NTEventLogAppender
log4j.appender.A3.layout=org.apache.log4j.PatternLayout
log4j.appender.A3.layout.ConversionPattern=%d|%l|%p|%t|%x|%m%n
log4j.appender.A3.threshold=FATAL
You may change only the ConversionPattern and threshold parameters.
The ConversionPattern parameter in the appender configurations determines what will be written to the log and what the data format will be. The following table describes the symbols. For a detailed description of all the variations of each of these symbols, see
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
Symbol |
Meaning |
%c |
Category or name of the logger. |
%C |
Class name of the caller. |
%d |
Date and time. |
%F |
Source file name of the caller. |
%l |
Location information of the caller, including class and method, source file name and line number. |
%L |
Line number of the caller. |
%m |
Text of message included in the logger call. |
%M |
Method name of the caller. |
%n |
Platform-dependent line termination character sequence. |
%p |
Priority or level of the logging call. |
%r |
Milliseconds elapsed since the start of the application. |
%t |
Thread name. |
%x |
Nested diagnostic context. |
%X |
Mapped diagnostic context. |
%% |
Include the % character in the output string. |
log4j.rootLogger=,A1
log4j.logger.com.unisys.os2200=,A1,A2,A3 <- Name of the log (com.unisys.os2200) and which log modules are active
# A1 is set to be a PluginFileAppender
log4j.appender.A1=com.unisys.logging.core.PluginFileAppender
log4j.appender.A1.MaxFileSize=5MB <- Maximum size before a new cycle is started
log4j.appender.A1.MaxBackupIndex=10 <- Number of cycles of the log to retain
log4j.appender.A1.File=/unisys-ca.log <- Name of the log file
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d:%p:%C{3}:%F:%L:%M:%t:%x :%m %n <- Format of the log entry
log4j.appender.A1.threshold=DEBUG <- The lowest level (severity) message that is written to this log module
# A2 is set to be a PluginLogAppender
log4j.appender.A2=com.unisys.logging.core.PluginLogAppender
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d|%l|%p|%t|%x|%m%n <- Format of the log entry
log4j.appender.A2.threshold=ERROR <- The lowest level (severity) message that is written to this log module
# A3 is set to be an NTEventLogAppender
log4j.appender.A3=com.unisys.logging.core.NTEventLogAppender
log4j.appender.A3.layout=org.apache.log4j.PatternLayout
log4j.appender.A3.layout.ConversionPattern=%d|%l|%p|%t|%x|%m%n <- Format of the log entry
log4j.appender.A3.threshold=FATAL <- The lowest level (severity) message that is written to this log module