









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










^ ConsoleAppenderConsoleAppender – sends messages to theconsole (stdout/stderr)console (stdout/stderr)^ FileAppenderFileAppender – sends messages to a file (whichyou name)you name) ``^ RollingFileAppenderRollingFileAppender – sends messages to a file,limited by length^ Each time length threshold is exceeded, a new file isstarted, with a new suffix^ You specify the main part of the file name andthreshold size
file limited by timefile, limited by time ^ Rolls over a new log file based on an interval (not limitedto days) and suffixes the file with the date/time^ You specify the main part of the file name and the interval
^ Layouts are how appenders format the logmessages sent to them by loggersmessages sent to them by loggers^ There are three layouts provided by log4j:^ `^XMLLayout – format the logging event as an xml line
y^
gg^
g
^ HTMLLayout – format the logging event as an HTML table^ PatternLayout – format the logging event as a printf-likestringstring
^ PatternLayout is the most commonly used option^^Used most frequently with File and Console appenders
q^
y^
pp
(i.e., clear text appenders), which are themselves themost common Very flexible Very flexible If you’ve ever done a SimpleDateFormat, you’ll knowwhat this is like:^^ “%-5p [%t]: %m%n” shows the severity the thread name the`^ %-5p [%t]: %m%n
shows the severity, the thread name, the
message, and a new line
^ log4j is typically configured using a simple propertiesfilefile^^You can use an xml file but most people use a propertiesfile ` You can also do it programmatically, but to change thingsrequires a recompile
^ At minimum, your config file:^^Defines the root loggerDefines the root logger^^ Defines what severity level of messages should be allowedthrough^ ^ Defines what appender(s) the messages should go to^ Defines what appender(s) the messages should go to Defines at least one appender^^ This in turn usually requires the specification of one layout
^ Chainsaw is a GUI log4j log viewer written andmaintained by the log4j teammaintained by the log4j team^ Can receive logging events sent directly via TCP/IP `^ Can also load an XML-layout log filey^
g
d h
JDK 1 4 l
i^
Th
id
i^ h
uses), and the JDK 1.4 logging API. The idea is thatyou can use JCL and not worry about which loggingimplementation is underneathimplementation is underneath.