Log Configuration
The log configuration is done in a configuration file for Log4CPlus
.
The configuration file can be edited in a text editor.
The default configuration contains 2 loggers, one console logger and one file logger.
The log configuration files are stored in the directory
$DDT_LOGCONFIG_PATH
. Each application uses its own configuration file.
The filename of the configuration file is made up of the prefix
log4cplus_
followed by the application name in lower case letters and
the extension .properties
(e.g.
log4cplus_ddtsubscribersimulator.properties
)
An example of the log configuration looks like this:
# Set options for appender named "ROLLING" # ROLLING should be a RollingFileAppender, with maximum file size of 10 MB # using at most one backup file. ROLLING's layout is TTCC, using the # ISO8061 date format with context printing enabled. log4cplus.rootLogger=INFO, ROLLING, STDOUT log4cplus.appender.ROLLING=log4cplus::RollingFileAppender log4cplus.appender.ROLLING.MaxFileSize=10MB log4cplus.appender.ROLLING.MaxBackupIndex=1 log4cplus.appender.ROLLING.layout=log4cplus::PatternLayout log4cplus.appender.ROLLING.layout.ConversionPattern=%d{%FT%T.%q} %-5p %m%n log4cplus.appender.ROLLING.File=${HOME}/ddtDataBroker.log log4cplus.appender.STDOUT=log4cplus::ConsoleAppender log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout log4cplus.appender.STDOUT.layout.ConversionPattern=%d{%FT%T.%q} %-5p %m%n
The log level for all log messages can be defined to use the level
DEBUG
, INFO
, WARNING
, ERROR
or FATAL
. In the example there is only one
log level set. It could also be set differently for different loggers.
The console logger in the example uses the name STDOUT
, while the file
logger uses a rolling file and is called ROLLING
.
The filename of the rolling file is configured in the item
log4cplus.appender.ROLLING.File
. In the example, it is set to a file
in the user’s home directory. The maximum size of the logfile is set to
10 MB and the number of backup files is set to 1.
Various other logger settings can be configured according on the Log4CPlus documentation on https://github.com/log4cplus/log4cplus