Logging to a File

Properties to send logging messages to a file.

To redirect the logging messages to a file instead of sending them to stdout, complete the following steps:

Procedure

  1. Edit the log4j.properties file in a text editor.
  2. Add the following properties:
    log4j.rootLogger = DEBUG, Console, file
    log4j.appender.file=org.apache.log4j.RollingFileAppender
    log4j.appender.file.File=test.log
    log4j.appender.file.MaxFileSize=10MB
    log4j.appender.file.MaxBackupIndex=2
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.file.layout.ConversionPattern=%m%n
  3. Save the changes to the file.