Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Emeeting module Log4j.

Emeeting module Log4j

From MoodleDocs
Revision as of 19:35, 3 August 2006 by Nitle Nite (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Headline text

The java servlets use Log4j for all the logging purposes. It includes two standard methods of outputting the logs, one to the console, the other is a Daily Rolling File Appender that will roll all the days logs into a new file every night at midnight. Log4j is configured in our code through a standard log4j property file that is just a simple text file.

The default log4j property file is:

log4j.rootLogger=DEBUG, console, logfile log4j.logger.TestLogProp=ERROR

log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%-5p %c %x - %m%n

log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.logfile.File=log\logout.txt log4j.appender.logfile.DatePattern='.'yyyy-MM-dd log4j.appender.logfile.Threshold=INFO log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%p %t %c -%m%n


It is strongly recommended that you change the default location, it will create a log folder in the location the servlets are run, which can be difficult to find.


Other things you might change:

    • The type of file that is used, there are several kinds
      • File Appender
      • Rolling File Appender
    • The Threshold level, it is currently set to info which includes all but the lowest level statements. You might need more or less, most of our statements are debug statements with simple method entrys.
      • DEBUG (lowest)
      • INFO
      • WARN (middle)
      • ERROR
      • FATAL (highest)
    • The Conversion Pattern, it currently uses a standard one but you may wish to configure it.
      • %p --The priority of the logging event(debug, warn)
      • %t --The name of the thread generating the event
      • %c --The category of the logging event
      • %m --message
      • %n --newline character
      • %d --date of the logging event
      • %l --Outputs the source code location information

For other information you can look at the following websites: This is the official Log4j Project home page that contains helpful information. Log4j Project - Introduction

This is a helpful walk through that is very thorough and helpful. Don't Use System.out.println!