You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2014/07/11 19:45:08 UTC

svn commit: r1609755 - in /logging/log4j/log4j2/trunk/src: changes/changes.xml site/xdoc/manual/api.xml

Author: rpopma
Date: Fri Jul 11 17:45:08 2014
New Revision: 1609755

URL: http://svn.apache.org/r1609755
Log:
LOG4J2-631: Update docs to clarify how to use formatter logger and standard logger together

Modified:
    logging/log4j/log4j2/trunk/src/changes/changes.xml
    logging/log4j/log4j2/trunk/src/site/xdoc/manual/api.xml

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1609755&r1=1609754&r2=1609755&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Fri Jul 11 17:45:08 2014
@@ -22,6 +22,9 @@
   </properties>
   <body>
     <release version="2.0-???" date="2014-0M-DD" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-631" dev="rpopma" type="fix">
+        Update docs to clarify how to use formatter logger and standard logger together.
+      </action>
       <action issue="LOG4J2-519" dev="rpopma" type="add">
         Added support for generating custom logger wrappers that replace the existing log levels
         and extended logger wrappers that add custom log levels to the existing ones.

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/api.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/api.xml?rev=1609755&r1=1609754&r2=1609755&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/api.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/api.xml Fri Jul 11 17:45:08 2014
@@ -100,7 +100,21 @@ logger.debug("Long.MAX_VALUE = %,d", Lon
 2012-12-12 11:56:19,643 [main] DEBUG: Integer.MAX_VALUE = 2,147,483,647
 2012-12-12 11:56:19,643 [main] DEBUG: Long.MAX_VALUE = 9,223,372,036,854,775,807
 </pre>
-          <h4>Logger names</h4>
+          <h4>Mixing Loggers with Formatter Loggers</h4>
+          <p>
+          Formatter loggers give fine-grained control over the output format, but have the drawback
+          that the correct type must be specified (for example, passing anything other than a decimal integer
+          for a %d format parameter gives an exception).
+          </p>
+          <p>
+          If your main usage is to use {}-style parameters, but occasionally you need fine-grained
+          control over the output format, you can use the <code>printf</code> method:</p>
+            <pre class="prettyprint linenums">public static Logger logger = LogManager.getLogger("Foo");
+
+logger.debug("Opening connection to {}...", someDataSource);
+logger.printf(Level.INFO, "Logging in user %1$s with birthday %2$tm %2$te,%2$tY", user.getName(), user.getBirthdayCalendar());
+</pre>
+          <h4>Logger Names</h4>
             <p>
               Most logging implementations use a hierarchical scheme for matching logger names with logging
               configuration. In this scheme the logger name hierarchy is represented by '.' characters in the