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 2015/09/12 12:57:20 UTC

logging-log4j2 git commit: LOG4J2-1118 added examples of extended logger support for java 8 lambda expressions

Repository: logging-log4j2
Updated Branches:
  refs/heads/master a61f1a129 -> 8c3db0854


LOG4J2-1118 added examples of extended logger support for java 8 lambda
expressions

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8c3db085
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8c3db085
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8c3db085

Branch: refs/heads/master
Commit: 8c3db08546993cb26d94b92924c1bca11003a355
Parents: a61f1a1
Author: rpopma <rp...@apache.org>
Authored: Sat Sep 12 19:57:14 2015 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Sep 12 19:57:14 2015 +0900

----------------------------------------------------------------------
 src/site/xdoc/manual/customloglevels.xml.vm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8c3db085/src/site/xdoc/manual/customloglevels.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/customloglevels.xml.vm b/src/site/xdoc/manual/customloglevels.xml.vm
index 4e48479..381d48f 100644
--- a/src/site/xdoc/manual/customloglevels.xml.vm
+++ b/src/site/xdoc/manual/customloglevels.xml.vm
@@ -213,7 +213,8 @@ logger.log(Level.forName("DIAG", 350), "another message");</pre>
             <pre class="prettyprint">
 // nice to have: descriptive methods and no need to pass the level as a parameter
 logger.verbose("a verbose message");
-logger.diag("another message");</pre>
+logger.diag("another message");
+logger.diag("java 8 lambda expression: {}", () -> someMethod());</pre>
             <p>The standard Logger interface cannot provide convenience methods for
               custom levels, but the next few sections introduce a code generation tool
               to create loggers that aim to make custom levels as easy to use
@@ -286,7 +287,7 @@ public class MyService {
     // instead of Logger logger = LogManager.getLogger(MyService.class):
     private static final ExtLogger logger = ExtLogger.create(MyService.class);
 
-    public void someMethod() {
+    public void demoExtendedLogger() {
         // ...
         logger.trace("the built-in TRACE level");
         logger.verbose("a custom level: a VERBOSE message");
@@ -297,6 +298,7 @@ public class MyService {
         logger.warn("the built-in WARN level");
         logger.error("the built-in ERROR level");
         logger.fatal("the built-in FATAL level");
+        logger.notice("java 8 lambda expression only executed if NOTICE is enabled: {}", () -> someMethod());
         // ...
     }
     ...