0% found this document useful (0 votes)
78 views2 pages

Log 4 J

The document explains how to configure logging using Log4j properties. It summarizes that the log4j.properties file sets the root logger priority to debug and defines two appenders - one for writing to the console and one for writing to a daily rolling file. It then provides details on the configuration properties for each appender and references log levels and appender types.

Uploaded by

Subin Ks
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views2 pages

Log 4 J

The document explains how to configure logging using Log4j properties. It summarizes that the log4j.properties file sets the root logger priority to debug and defines two appenders - one for writing to the console and one for writing to a daily rolling file. It then provides details on the configuration properties for each appender and references log levels and appender types.

Uploaded by

Subin Ks
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Log4j.properties file explained #Set root category priority to debug and its appender to stdout.

A should be used in case you want to store the log data. log4j.rootCategory=debug, stdout, A # stdout is set to be a ConsoleAppender using a PatternLayout. log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %m%n Storing the log information # Log gets appended to the file created daily. log4j.appender.A=org.apache.log4j.DailyRollingFileAppender # The file will be stored in the path given in this command. log4j.appender.A.File=/home/user/log/pmgraph.log log4j.appender.A.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name, line number, and date and time. log4j.appender.A.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %5p %t (%F:%L) %m%n Reference Priorities Level ALL: TRACE: DEBUG: INFO: WARN: ERROR: FATAL: OFF: Description Output of all messages Detailed Debugging Debugging (Method xy called with param abc ) General information (Program started/ended, connected to host foo, calculation took n seconds) Unexpected situation Error (Exception caught) Critical error, program stops Logging is deactivated

Usage: log4j.rootLogger=Level, Appender, Appender, ... Appenders Name ConsoleAppender: FileAppender: RollingFileAppender: DailyRollingFileAppender: SyslogAppender: NTEventLogAppender: SMTPAppender: net.SocketAppender: net.SocketHubAppender:

Writes to Stdandard Output (Console) File File, creates a new based on file size File, creates a new based on time UNIX Syslog Windows Event-Log e-mail Socket (client mode) Socket (server mode)

Usage: log4j.appender.Appender=org.apache.log4j.Name Layouts Name PatternLayout: SimpleLayout: TTCCLayout: HTMLLayout: XMLLayout:

Description Conversion Pattern Level and Message = time, thread, category, context HTML Table XML

Usage: log4j.appender.Appender.layout=org.apache.log4j.Name PatternLayout c category; a.b.c -> %c{2} = a.b C fully qualified class name (slow); org.apache.xyz.SomeClass -> %C{1} = SomeClass d date; %d{HH:mm:ss,SSS}, %d{ABSOLUTE}, %d{DATE}, %d{ISO8601} construction F file name (extremly slow) l location (extremly slow) thread L line number (extremly slow) thred; %X{clientNumber} % percent sign Format Modifier Modifier left justify %20c false than 20 characters long. %-20c true than 20 characters long. %.30c NA longer than 30 characters. %20.30c false than 20 characters. characters, then truncate %-20.30c true shorter than 20 characters. characters, then truncate 20 30

m message M method name (extremly slow) n line separator; \n or \r\n p priority r milliseconds from layout t thread name x nested diagnostic context of X mapped diagnositc context of

min.

max. comment width width 20 none Left pad with spaces if the name is less 20 none 20 none 30 30 Right pad with spaces if the name is less Truncate from the beginning if the name is Left pad with spaces if the name is shorter However, if category name is longer than 30 from the beginning. Right pad with spaces if the name is However, if category name is longer than 30 from the beginning.

You might also like