Differences between revisions 6 and 7
Revision 6 as of 2011-04-13 15:44:32
Size: 1796
Editor: JacobAnawalt
Comment: Fixed inconsistent use of logger name in example.
Revision 7 as of 2013-01-22 13:58:31
Size: 1827
Comment: fix link to API doc for pattern layout
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
The most flexible of all the API provided Layout objects, it applies ''printf'' like formatting to the output allowing you to include or exclude options like the logger name, date, log location, priority, NDC, MDC and of course your message. The [[http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html|API Documentation for it]] lists the /ConversionPattern conversion characters and their effects. The most flexible of all the API provided Layout objects, it applies ''printf'' like formatting to the output allowing you to include or exclude options like the logger name, date, log location, priority, NDC, MDC and of course your message. The [[https://svn.apache.org/repos/asf/logging/site/trunk/docs/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html|API Documentation for it]] lists the /ConversionPattern conversion characters and their effects.

The most flexible of all the API provided Layout objects, it applies printf like formatting to the output allowing you to include or exclude options like the logger name, date, log location, priority, NDC, MDC and of course your message. The API Documentation for it lists the /ConversionPattern conversion characters and their effects.

In addition to this built-in layout, likely candidates for console and syslog output include TTCCLayout and SimpleLayout. The layout is set per appender.

If the /ConversionPattern specifies fields that your code does not provide, like a NestedDiagnosticContexts or a line number, it may output a whatever the initial value of is for the object (like an empty string or -1). Your code needs to provide the data if you want to log it. Once it's provided you can choose to use it or not based on the configuration.

log4j.appender.C=org.apache.log4j.ConsoleAppender
log4j.appender.C.layout=org.apache.log4j.PatternLayout
log4j.appender.C.layout.ConversionPattern=%d{%Y-%m-%d %H:%M:%S} %-5p %c %x - %m%n

See Also

Mailing List


CategoryApiDocs

PatternLayout (last edited 2013-01-22 13:58:31 by Christian Boos)