See (LOG4J2-905) Ability to disable (date) lookup completely, compatibility issues with other libraries like camel. This shows the behavior this user wants to disable.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c18ba5a9 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c18ba5a9 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c18ba5a9 Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure Commit: c18ba5a9ee3f30957ade35279d09d55f51b76675 Parents: 78764b3 Author: Gary Gregory <ggreg...@apache.org> Authored: Thu Aug 18 23:02:02 2016 -0700 Committer: Gary Gregory <ggreg...@apache.org> Committed: Thu Aug 18 23:02:02 2016 -0700 ---------------------------------------------------------------------- .../layout/PatternLayoutLookupDateTest.java | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c18ba5a9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutLookupDateTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutLookupDateTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutLookupDateTest.java new file mode 100644 index 0000000..61769b7 --- /dev/null +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutLookupDateTest.java @@ -0,0 +1,26 @@ +package org.apache.logging.log4j.core.layout; + +import org.apache.logging.log4j.junit.LoggerContextRule; +import org.apache.logging.log4j.test.appender.ListAppender; +import org.junit.Assert; +import org.junit.ClassRule; +import org.junit.Test; + +/** + * See (LOG4J2-905) Ability to disable (date) lookup completely, compatibility issues with other libraries like camel. + * + * This shows the behavior this user wants to disable. + */ +public class PatternLayoutLookupDateTest { + + @ClassRule + public static LoggerContextRule context = new LoggerContextRule("log4j-list.xml"); + + @Test + public void testDateLookupInMessage() { + context.getLogger(PatternLayoutLookupDateTest.class.getName()).info("${date:now:buhu}"); + final ListAppender listAppender = context.getListAppender("List"); + Assert.assertNotEquals("${date:now:buhu}", listAppender.getMessages().get(0)); + } + +}