Howto: Output all log messages to a file¶
The following logger configuration file (log2file.cfg
) shows how to redirect all output to a file:
log4cplus.rootLogger = INFO, logfile log4cplus.appender.logfile = log4cplus::FileAppender log4cplus.appender.logfile.File = dcmtk.log log4cplus.appender.logfile.Append = true log4cplus.appender.logfile.ImmediateFlush = true log4cplus.appender.logfile.layout = log4cplus::PatternLayout log4cplus.appender.logfile.layout.ConversionPattern = %D{%Y-%m-%d %H:%M:%S.%q} %5p: %m%n
Just call the desired DCMTK command line tool with option "--log-config log2file.cfg
" and all output will only be written to the file "dcmtk.log
" and not to the console.
If you also want to see debug messages together with the name of the module (in fact, it's the last component of the logger name) and the source file plus the line number where the message was generated, use something like the following:
log4cplus.rootLogger = DEBUG, logfile ... log4cplus.appender.logfile.layout.ConversionPattern = %D{%Y-%m-%d %H:%M:%S.%q} %5p - %c{1} / %l - %m%n
Note¶
Please note that the --log-config
option requires DCMTK 3.5.5 (20091222) or newer.
There is another example configuration file filelog.cfg in the source code repository.