|
Log4j 1.3alpha-8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.log4j.spi.ComponentBase | +--org.apache.log4j.Layout | +--org.apache.log4j.helpers.DateLayout | +--org.apache.log4j.TTCCLayout
PatternLayout
instead.
TTCC layout format consists of time, thread, category and nested diagnostic context information, hence the name.
Each of the four fields can be individually enabled or
disabled. The time format depends on the DateFormat
used.
Here is an example TTCCLayout output with the
RelativeTimeDateFormat
.
176 [main] INFO org.apache.log4j.examples.Sort - Populating an array of 2 elements in reverse order. 225 [main] INFO org.apache.log4j.examples.SortAlgo - Entered the sort method. 262 [main] DEBUG org.apache.log4j.examples.SortAlgo.OUTER i=1 - Outer loop. 276 [main] DEBUG org.apache.log4j.examples.SortAlgo.SWAP i=1 j=0 - Swapping intArray[0] = 1 and intArray[1] = 0 290 [main] DEBUG org.apache.log4j.examples.SortAlgo.OUTER i=0 - Outer loop. 304 [main] INFO org.apache.log4j.examples.SortAlgo.DUMP - Dump of interger array: 317 [main] INFO org.apache.log4j.examples.SortAlgo.DUMP - Element [0] = 0 331 [main] INFO org.apache.log4j.examples.SortAlgo.DUMP - Element [1] = 1 343 [main] INFO org.apache.log4j.examples.Sort - The next log statement should be an error message. 346 [main] ERROR org.apache.log4j.examples.SortAlgo.DUMP - Tried to dump an uninitialized array. at org.apache.log4j.examples.SortAlgo.dump(SortAlgo.java:58) at org.apache.log4j.examples.Sort.main(Sort.java:64) 467 [main] INFO org.apache.log4j.examples.Sort - Exiting main method.
The first field is the number of milliseconds elapsed since the start of the program. The second field is the thread outputting the log statement. The third field is the level, the fourth field is the category to which the statement belongs.
The fifth field (just before the '-') is the nested diagnostic context. Note the nested diagnostic context may be empty as in the first two statements. The text after the '-' is the message of the statement.
PatternLayout
offers a much more flexible alternative.
Field Summary | |
protected StringBuffer |
buf
Deprecated. |
Fields inherited from class org.apache.log4j.helpers.DateLayout |
date, DATE_FORMAT_OPTION, dateFormat, NULL_DATE_FORMAT, pos, RELATIVE_TIME_DATE_FORMAT, TIMEZONE_OPTION |
Fields inherited from class org.apache.log4j.Layout |
ignoresThrowable, LINE_SEP, LINE_SEP_LEN |
Fields inherited from class org.apache.log4j.spi.ComponentBase |
repository |
Constructor Summary | |
TTCCLayout()
Deprecated. Instantiate a TTCCLayout object with in the ISO8601 format as the date formatter. |
|
TTCCLayout(String dateFormatType)
Deprecated. Instantiate a TTCCLayout object using the local time zone. |
Method Summary | |
void |
activateOptions()
Deprecated. Activate the options that were previously set with calls to option setters. |
String |
format(LoggingEvent event)
Deprecated. In addition to the level of the statement and message, the returned byte array includes time, thread, category and NDC
information. |
boolean |
getCategoryPrefixing()
Deprecated. Returns value of the CategoryPrefixing option. |
boolean |
getContextPrinting()
Deprecated. Returns value of the ContextPrinting option. |
boolean |
getThreadPrinting()
Deprecated. Returns value of the ThreadPrinting option. |
void |
setCategoryPrefixing(boolean categoryPrefixing)
Deprecated. The CategoryPrefixing option specifies whether Category
name is part of log output or not. |
void |
setContextPrinting(boolean contextPrinting)
Deprecated. The ContextPrinting option specifies log output will include the nested context information belonging to the current thread. |
void |
setThreadPrinting(boolean threadPrinting)
Deprecated. The ThreadPrinting option specifies whether the name of the current thread is part of log output or not. |
Methods inherited from class org.apache.log4j.helpers.DateLayout |
dateFormat, getDateFormat, getOptionStrings, getTimeZone, setDateFormat, setDateFormat, setDateFormat, setOption, setTimeZone |
Methods inherited from class org.apache.log4j.Layout |
getContentType, getFooter, getHeader, ignoresThrowable, setFooter, setHeader, setIgnoresThrowable |
Methods inherited from class org.apache.log4j.spi.ComponentBase |
getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, setLoggerRepository |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final StringBuffer buf
Constructor Detail |
public TTCCLayout()
public TTCCLayout(String dateFormatType)
dateFormatType
.
This constructor just calls the DateLayout.setDateFormat(java.lang.String)
method.
Method Detail |
public void activateOptions()
OptionHandler
This allows to defer activiation of the options until all options have been set. This is required for components which have related options that remain ambigous until all are set.
For example, the FileAppender has the File
and Append
options both of
which are ambigous until the other is also set.
activateOptions
in class DateLayout
public void setThreadPrinting(boolean threadPrinting)
public boolean getThreadPrinting()
public void setCategoryPrefixing(boolean categoryPrefixing)
Category
name is part of log output or not. This is true by default.public boolean getCategoryPrefixing()
public void setContextPrinting(boolean contextPrinting)
public boolean getContextPrinting()
public String format(LoggingEvent event)
NDC
information.
Time, thread, category and diagnostic context are printed depending on options.
format
in class Layout
|
Log4j 1.3alpha-8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |