logging-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikael Ståldal <mi...@apache.org>
Subject Re: logging-log4j2 git commit: LOG4J2-2087 Jansi now needs to be enabled explicitly (by setting system property `log4j.skipJansi` to `false`). To avoid causing problems for web applications, Log4j will no longer automatically try to load Jansi without explic
Date Tue, 24 Oct 2017 19:40:25 GMT
If we are going to rename it, I would like to invert it to 
"log4j2.enableJansi" (default false). I think negative properties with 
true default are confusing.


On 2017-10-24 15:04, Remko Popma wrote:
> You mean let’s replace all occurrences of `log4j.skipJansi` with `log4j2.skipJansi`,
in both code and documentation?
> 
> 
> 
>> On Oct 24, 2017, at 14:03, Matt Sicker <boards@gmail.com> wrote:
>>
>> Can you use the new system property naming scheme? This would be
>> log4j2.skipJansi. That property would work regardless with the new system
>> properties parser thing, though the documentation should be more consistent
>> now.
>>
>>> On 23 October 2017 at 22:14, <rpopma@apache.org> wrote:
>>>
>>> Repository: logging-log4j2
>>> Updated Branches:
>>>   refs/heads/master 00823bd95 -> 73efe3dcf
>>>
>>>
>>> LOG4J2-2087 Jansi now needs to be enabled explicitly (by setting system
>>> property `log4j.skipJansi` to `false`). To avoid causing problems for web
>>> applications, Log4j will no longer automatically try to load Jansi without
>>> explicit configuration.
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/
>>> commit/73efe3dc
>>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/73efe3dc
>>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/73efe3dc
>>>
>>> Branch: refs/heads/master
>>> Commit: 73efe3dcf6787e66177a6485271362c5f989e014
>>> Parents: 00823bd
>>> Author: rpopma <rpopma@apache.org>
>>> Authored: Tue Oct 24 12:13:56 2017 +0900
>>> Committer: rpopma <rpopma@apache.org>
>>> Committed: Tue Oct 24 12:13:56 2017 +0900
>>>
>>> ----------------------------------------------------------------------
>>> .../log4j/core/appender/ConsoleAppender.java    | 10 ++--
>>> .../log4j/core/layout/PatternLayout.java        | 16 +++++--
>>> .../ConsoleAppenderAnsiMessagesMain.java        |  3 +-
>>> .../ConsoleAppenderAnsiStyleJira180Main.java    |  3 +-
>>> .../ConsoleAppenderAnsiStyleJira272Main.java    |  1 +
>>> .../ConsoleAppenderAnsiStyleJira319Main.java    |  3 +-
>>> .../ConsoleAppenderAnsiStyleLayoutMain.java     |  3 +-
>>> .../ConsoleAppenderAnsiStyleNameLayoutMain.java |  1 +
>>> ...nsoleAppenderHighlightLayoutDefaultMain.java |  1 +
>>> .../ConsoleAppenderHighlightLayoutMain.java     |  1 +
>>> .../ConsoleAppenderJAnsiMessageMain.java        |  7 +--
>>> .../ConsoleAppenderJAnsiXExceptionMain.java     |  7 +--
>>> .../ConsoleAppenderNoAnsiStyleLayoutMain.java   |  2 +-
>>> .../log4j/core/pattern/StyleConverterTest.java  |  6 +++
>>> src/changes/changes.xml                         |  3 ++
>>> src/site/xdoc/manual/layouts.xml.vm             | 48 ++++++++++++--------
>>> 16 files changed, 76 insertions(+), 39 deletions(-)
>>> ----------------------------------------------------------------------
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/main/java/org/apache/logging/log4j/
>>> core/appender/ConsoleAppender.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppender.java
>>> index bd2dc16..90d16e6 100644
>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppender.java
>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppender.java
>>> @@ -67,7 +67,7 @@ public final class ConsoleAppender extends
>>> AbstractOutputStreamAppender<OutputSt
>>>       * Enumeration of console destinations.
>>>       */
>>>      public enum Target {
>>> -
>>> +
>>>          /** Standard output. */
>>>          SYSTEM_OUT {
>>>              @Override
>>> @@ -76,7 +76,7 @@ public final class ConsoleAppender extends
>>> AbstractOutputStreamAppender<OutputSt
>>>                  return getCharset("sun.stdout.encoding",
>>> Charset.defaultCharset());
>>>              }
>>>          },
>>> -
>>> +
>>>          /** Standard error output. */
>>>          SYSTEM_ERR {
>>>              @Override
>>> @@ -85,9 +85,9 @@ public final class ConsoleAppender extends
>>> AbstractOutputStreamAppender<OutputSt
>>>                  return getCharset("sun.stderr.encoding",
>>> Charset.defaultCharset());
>>>              }
>>>          };
>>> -
>>> +
>>>          public abstract Charset getDefaultCharset();
>>> -
>>> +
>>>          protected Charset getCharset(final String property, Charset
>>> defaultCharset) {
>>>              return new PropertiesUtil(PropertiesUtil.
>>> getSystemProperties()).getCharsetProperty(property, defaultCharset);
>>>          }
>>> @@ -260,7 +260,7 @@ public final class ConsoleAppender extends
>>> AbstractOutputStreamAppender<OutputSt
>>>              throw new IllegalStateException("Unsupported default
>>> encoding " + enc, ex);
>>>          }
>>>          final PropertiesUtil propsUtil = PropertiesUtil.getProperties();
>>> -        if (!propsUtil.isOsWindows() || propsUtil.getBooleanProperty("log4j.skipJansi")
>>> || direct) {
>>> +        if (!propsUtil.isOsWindows() || propsUtil.getBooleanProperty("log4j.skipJansi",
>>> true) || direct) {
>>>              return outputStream;
>>>          }
>>>          try {
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/main/java/org/apache/logging/log4j/
>>> core/layout/PatternLayout.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/
>>> layout/PatternLayout.java
>>> index e4440eb..a6b3a88 100644
>>> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/
>>> layout/PatternLayout.java
>>> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/
>>> layout/PatternLayout.java
>>> @@ -38,6 +38,7 @@ import org.apache.logging.log4j.core.pattern.
>>> LogEventPatternConverter;
>>> import org.apache.logging.log4j.core.pattern.PatternFormatter;
>>> import org.apache.logging.log4j.core.pattern.PatternParser;
>>> import org.apache.logging.log4j.core.pattern.RegexReplacement;
>>> +import org.apache.logging.log4j.util.PropertiesUtil;
>>> import org.apache.logging.log4j.util.Strings;
>>>
>>> /**
>>> @@ -143,7 +144,7 @@ public final class PatternLayout extends
>>> AbstractStringLayout {
>>>
>>>      /**
>>>       * Deprecated, use {@link #newSerializerBuilder()} instead.
>>> -     *
>>> +     *
>>>       * @param configuration
>>>       * @param replace
>>>       * @param pattern
>>> @@ -427,7 +428,7 @@ public final class PatternLayout extends
>>> AbstractStringLayout {
>>>      }
>>>
>>>      private static class PatternSelectorSerializer implements Serializer,
>>> Serializer2 {
>>> -
>>> +
>>>          private final PatternSelector patternSelector;
>>>          private final RegexReplacement replace;
>>>
>>> @@ -535,7 +536,7 @@ public final class PatternLayout extends
>>> AbstractStringLayout {
>>>          private boolean alwaysWriteExceptions = true;
>>>
>>>          @PluginBuilderAttribute
>>> -        private boolean disableAnsi;
>>> +        private boolean disableAnsi = !useAnsiEscapeCodes();
>>>
>>>          @PluginBuilderAttribute
>>>          private boolean noConsoleNoAnsi;
>>> @@ -549,6 +550,12 @@ public final class PatternLayout extends
>>> AbstractStringLayout {
>>>          private Builder() {
>>>          }
>>>
>>> +        private boolean useAnsiEscapeCodes() {
>>> +            PropertiesUtil propertiesUtil = PropertiesUtil.getProperties()
>>> ;
>>> +            boolean isPlatformSupportsAnsi =
>>> !propertiesUtil.isOsWindows();
>>> +            boolean isJansiRequested = !propertiesUtil.
>>> getBooleanProperty("log4j.skipJansi", true);
>>> +            return isPlatformSupportsAnsi || isJansiRequested;
>>> +        }
>>>
>>>          /**
>>>           * @param pattern
>>> @@ -609,7 +616,8 @@ public final class PatternLayout extends
>>> AbstractStringLayout {
>>>
>>>          /**
>>>           * @param disableAnsi
>>> -         *        If {@code "true"} (default is false), do not output
>>> ANSI escape codes
>>> +         *        If {@code "true"} (default is value of system property
>>> `log4j.skipJansi`, or `true` if undefined),
>>> +         *        do not output ANSI escape codes
>>>           */
>>>          public Builder withDisableAnsi(final boolean disableAnsi) {
>>>              this.disableAnsi = disableAnsi;
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiMessagesMain.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderAnsiMessagesMain.java b/log4j-core/src/test/java/
>>> org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiMessagesMai
>>> n.java
>>> index f8ea731..f74ab1b 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiMessagesMain.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiMessagesMain.java
>>> @@ -29,7 +29,7 @@ import org.apache.logging.log4j.core.
>>> config.Configurator;
>>>   * <p>
>>>   * Running from a Windows command line from the root of the project:
>>>   * </p>
>>> - *
>>> + *
>>>   * <pre>
>>>   * java -classpath log4j-core¥target¥test-classes;log4j-core¥target¥
>>> classes;log4j-api¥target¥classes;%HOME%¥.m2¥repository¥
>>> org¥fusesource¥jansi¥jansi¥1.14¥jansi-1.14.jar;
>>> org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiMessagesMain
>>> log4j-core/target/test-classes/log4j2-console.xml
>>>   * </pre>
>>> @@ -39,6 +39,7 @@ public class ConsoleAppenderAnsiMessagesMain {
>>>      private static final Logger LOG = LogManager.getLogger(
>>> ConsoleAppenderAnsiMessagesMain.class);
>>>
>>>      public static void main(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          try (final LoggerContext ctx = Configurator.initialize(
>>> ConsoleAppenderAnsiMessagesMain.class.getName(),
>>>                  "target/test-classes/log4j2-console.xml")) {
>>>              LOG.fatal("¥u001b[1;35mFatal message.¥u001b[0m");
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira180Main.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderAnsiStyleJira180Main.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira180Main.java
>>> index 5a7fcee..5bb815d 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira180Main.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira180Main.java
>>> @@ -27,7 +27,7 @@ import org.apache.logging.log4j.core.
>>> config.Configurator;
>>>   * <p>
>>>   * Running from a Windows command line from the root of the project:
>>>   * </p>
>>> - *
>>> + *
>>>   * <pre>
>>>   * java -classpath log4j-core¥target¥test-classes;log4j-core¥target¥
>>> classes;log4j-api¥target¥classes;%HOME%¥.m2¥repository¥
>>> org¥fusesource¥jansi¥jansi¥1.14¥jansi-1.14.jar;
>>> org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleJira180Main
>>> log4j-core/target/test-classes/log4j2-180.xml
>>>   * </pre>
>>> @@ -37,6 +37,7 @@ public class ConsoleAppenderAnsiStyleJira180Main {
>>>      private static final Logger LOG = LogManager.getLogger(
>>> ConsoleAppenderAnsiStyleJira180Main.class);
>>>
>>>      public static void main(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          // System.out.println(System.getProperty("java.class.path"));
>>>          final String config = args.length == 0 ?
>>> "target/test-classes/log4j2-180.xml" : args[0];
>>>          try (final LoggerContext ctx = Configurator.initialize(
>>> ConsoleAppenderAnsiMessagesMain.class.getName(),
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira272Main.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderAnsiStyleJira272Main.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira272Main.java
>>> index 9889f46..8c8aaa9 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira272Main.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira272Main.java
>>> @@ -36,6 +36,7 @@ public class ConsoleAppenderAnsiStyleJira272Main {
>>>      private static final Logger LOG = LogManager.getLogger(
>>> ConsoleAppenderAnsiStyleJira272Main.class);
>>>
>>>      public static void main(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          // System.out.println(System.getProperty("java.class.path"));
>>>          final String config = args.length == 0 ?
>>> "target/test-classes/log4j2-272.xml" : args[0];
>>>          try (final LoggerContext ctx = Configurator.initialize(
>>> ConsoleAppenderAnsiMessagesMain.class.getName(), config)) {
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira319Main.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderAnsiStyleJira319Main.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira319Main.java
>>> index 54ad06c..9d62101 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira319Main.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleJira319Main.java
>>> @@ -27,7 +27,7 @@ import org.apache.logging.log4j.core.
>>> config.Configurator;
>>>   * <p>
>>>   * Running from a Windows command line from the root of the project:
>>>   * </p>
>>> - *
>>> + *
>>>   * <pre>
>>>   * java -classpath log4j-core¥target¥test-classes;log4j-core¥target¥
>>> classes;log4j-api¥target¥classes;%HOME%¥.m2¥repository¥
>>> org¥fusesource¥jansi¥jansi¥1.14¥jansi-1.14.jar;
>>> org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleJira319Main
>>> log4j-core/target/test-classes/log4j2-319.xml
>>>   * </pre>
>>> @@ -37,6 +37,7 @@ public class ConsoleAppenderAnsiStyleJira319Main {
>>>      private static final Logger LOG = LogManager.getLogger(
>>> ConsoleAppenderAnsiStyleJira319Main.class);
>>>
>>>      public static void main(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          // System.out.println(System.getProperty("java.class.path"));
>>>          final String config = args.length == 0 ?
>>> "target/test-classes/log4j2-319.xml" : args[0];
>>>          try (final LoggerContext ctx = Configurator.initialize(
>>> ConsoleAppenderAnsiMessagesMain.class.getName(),
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleLayoutMain.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderAnsiStyleLayoutMain.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleLayoutMain.java
>>> index 5e3bb0f..758b13e 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleLayoutMain.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleLayoutMain.java
>>> @@ -38,7 +38,7 @@ import org.junit.Test;
>>>   * <pre>
>>>   * java -classpath log4j-core¥target¥test-classes;log4j-core¥target¥
>>> classes;log4j-api¥target¥classes;%HOME%¥.m2¥repository¥
>>> org¥fusesource¥jansi¥jansi¥1.14¥jansi-1.14.jar;
>>> org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleLayoutMain
>>> log4j-core/target/test-classes/log4j2-console-style-ansi.xml
>>>   * </pre>
>>> - *
>>> + *
>>>   */
>>> public class ConsoleAppenderAnsiStyleLayoutMain {
>>>
>>> @@ -55,6 +55,7 @@ public class ConsoleAppenderAnsiStyleLayoutMain {
>>>      }
>>>
>>>      public void test(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          // System.out.println(System.getProperty("java.class.path"));
>>>          final String config = args == null || args.length == 0 ?
>>> "target/test-classes/log4j2-console-style-ansi.xml"
>>>                  : args[0];
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleNameLayoutMain.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderAnsiStyleNameLayoutMain.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleNameLayoutMain.java
>>> index 4a2b26a..09f111b 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleNameLayoutMain.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderAnsiStyleNameLayoutMain.java
>>> @@ -32,6 +32,7 @@ public class ConsoleAppenderAnsiStyleNameLayoutMain {
>>>      private static final Logger LOG = LogManager.getLogger(
>>> ConsoleAppenderAnsiStyleNameLayoutMain.class);
>>>
>>>      public static void main(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          try (final LoggerContext ctx = Configurator.initialize(
>>> ConsoleAppenderAnsiMessagesMain.class.getName(),
>>>                  "target/test-classes/log4j2-console-style-name-ansi.xml"))
>>> {
>>>              LOG.fatal("Fatal message.");
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderHighlightLayoutDefaultMain.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderHighlightLayoutDefaultMain.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderHighlightLayoutDefaultMain.java
>>> index 4c3339d..16afa9b 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderHighlightLayoutDefaultMain.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderHighlightLayoutDefaultMain.java
>>> @@ -32,6 +32,7 @@ public class ConsoleAppenderHighlightLayoutDefaultMain {
>>>      private static final Logger LOG = LogManager.getLogger(
>>> ConsoleAppenderHighlightLayoutDefaultMain.class);
>>>
>>>      public static void main(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          try (final LoggerContext ctx = Configurator.initialize(
>>> ConsoleAppenderAnsiMessagesMain.class.getName(),
>>>                  "target/test-classes/log4j2-
>>> console-highlight-default.xml")) {
>>>              LOG.fatal("Fatal message.");
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderHighlightLayoutMain.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderHighlightLayoutMain.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderHighlightLayoutMain.java
>>> index 0ca7e8d..34c4355 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderHighlightLayoutMain.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderHighlightLayoutMain.java
>>> @@ -32,6 +32,7 @@ public class ConsoleAppenderHighlightLayoutMain {
>>>      private static final Logger LOG = LogManager.getLogger(
>>> ConsoleAppenderHighlightLayoutMain.class);
>>>
>>>      public static void main(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          try (final LoggerContext ctx = Configurator.initialize(
>>> ConsoleAppenderAnsiMessagesMain.class.getName(),
>>>                  "target/test-classes/log4j2-console-highlight.xml")) {
>>>              LOG.fatal("Fatal message.");
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderJAnsiMessageMain.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderJAnsiMessageMain.java b/log4j-core/src/test/java/
>>> org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMai
>>> n.java
>>> index 6e54505..f800806 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderJAnsiMessageMain.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderJAnsiMessageMain.java
>>> @@ -40,13 +40,13 @@ import org.junit.experimental.categories.Category;
>>>   * <pre>
>>>   * mvn -Dtest=org.apache.logging.log4j.core.appender.
>>> ConsoleAppenderJAnsiMessageMain test
>>>   * </pre>
>>> - *
>>> + *
>>>   * or, on Windows:
>>> - *
>>> + *
>>>   * <pre>
>>>   * java -classpath log4j-core¥target¥test-classes;log4j-core¥target¥
>>> classes;log4j-api¥target¥classes;%USERPROFILE%¥.m2¥
>>> repository¥org¥fusesource¥jansi¥jansi¥1.14¥jansi-1.14.jar;
>>> org.apache.logging.log4j.core.appender.ConsoleAppenderJAnsiMessageMain
>>> log4j-core/src/test/resources/log4j2-console-msg-ansi.xml
>>>   * </pre>
>>> - *
>>> + *
>>>   */
>>> @Category(Layouts.Jansi.class)
>>> public class ConsoleAppenderJAnsiMessageMain {
>>> @@ -64,6 +64,7 @@ public class ConsoleAppenderJAnsiMessageMain {
>>>      }
>>>
>>>      public void test(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          // System.out.println(System.getProperty("java.class.path"));
>>>          final String config = args == null || args.length == 0 ?
>>> "target/test-classes/log4j2-console-msg-ansi.xml"
>>>                  : args[0];
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderJAnsiXExceptionMain.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderJAnsiXExceptionMain.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderJAnsiXExceptionMain.java
>>> index 7780a1d..34901ff 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderJAnsiXExceptionMain.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderJAnsiXExceptionMain.java
>>> @@ -37,13 +37,13 @@ import org.junit.experimental.categories.Category;
>>>   * <pre>
>>>   * mvn -Dtest=org.apache.logging.log4j.core.appender.
>>> ConsoleAppenderJAnsiXExceptionMain test
>>>   * </pre>
>>> - *
>>> + *
>>>   * or, on Windows:
>>> - *
>>> + *
>>>   * <pre>
>>>   * java -classpath log4j-core¥target¥test-classes;log4j-core¥target¥
>>> classes;log4j-api¥target¥classes;%USERPROFILE%¥.m2¥
>>> repository¥org¥fusesource¥jansi¥jansi¥1.14¥jansi-1.14.jar;
>>> org.apache.logging.log4j.core.appender.ConsoleAppenderJAnsiXExceptionMain
>>> log4j-core/src/test/resources/log4j2-console-xex-ansi.xml
>>>   * </pre>
>>> - *
>>> + *
>>>   */
>>> @Category(Layouts.Jansi.class)
>>> public class ConsoleAppenderJAnsiXExceptionMain {
>>> @@ -61,6 +61,7 @@ public class ConsoleAppenderJAnsiXExceptionMain {
>>>      }
>>>
>>>      public void test(final String[] args) {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>>          // System.out.println(System.getProperty("java.class.path"));
>>>          final String config = args == null || args.length == 0 ?
>>> "target/test-classes/log4j2-console-xex-ansi.xml"
>>>                  : args[0];
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderNoAnsiStyleLayoutMain.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> appender/ConsoleAppenderNoAnsiStyleLayoutMain.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderNoAnsiStyleLayoutMain.java
>>> index bb08de4..3bc22d1 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderNoAnsiStyleLayoutMain.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/
>>> ConsoleAppenderNoAnsiStyleLayoutMain.java
>>> @@ -29,7 +29,7 @@ import org.apache.logging.log4j.core.
>>> config.Configurator;
>>>   * <p>
>>>   * Running from a Windows command line from the root of the project:
>>>   * </p>
>>> - *
>>> + *
>>>   * <pre>
>>>   * java -classpath log4j-core¥target¥test-classes;log4j-core¥target¥
>>> classes;log4j-api¥target¥classes;%HOME%¥.m2¥repository¥
>>> org¥fusesource¥jansi¥jansi¥1.14¥jansi-1.14.jar;
>>> org.apache.logging.log4j.core.appender.ConsoleAppenderNoAnsiStyleLayoutMain
>>> log4j-core/target/test-classes/log4j2-console-style-ansi.xml
>>>   * </pre>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/
>>> StyleConverterTest.java
>>> ----------------------------------------------------------------------
>>> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> pattern/StyleConverterTest.java b/log4j-core/src/test/java/
>>> org/apache/logging/log4j/core/pattern/StyleConverterTest.java
>>> index ea62885..248fdc3 100644
>>> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> pattern/StyleConverterTest.java
>>> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/
>>> pattern/StyleConverterTest.java
>>> @@ -24,6 +24,7 @@ import org.apache.logging.log4j.test.
>>> appender.ListAppender;
>>> import org.apache.logging.log4j.util.Strings;
>>> import org.junit.Assert;
>>> import org.junit.Before;
>>> +import org.junit.BeforeClass;
>>> import org.junit.Rule;
>>> import org.junit.Test;
>>>
>>> @@ -38,6 +39,11 @@ public class StyleConverterTest {
>>>          "¥u001B[1;31mERROR¥u001B[m ¥u001B[1;36mLoggerTest¥u001B[m
>>> o.a.l.l.c.p.StyleConverterTest org.apache.logging.log4j.core.
>>> pattern.StyleConverterTest"
>>>          + Strings.LINE_SEPARATOR;
>>>
>>> +    @BeforeClass
>>> +    public static void beforeClass() {
>>> +        System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087:
>>> explicitly enable
>>> +    }
>>> +
>>>      @Rule
>>>      public LoggerContextRule init = new LoggerContextRule("log4j-
>>> style.xml");
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/src/changes/changes.xml
>>> ----------------------------------------------------------------------
>>> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
>>> index b8d560e..9dbdd75 100644
>>> --- a/src/changes/changes.xml
>>> +++ b/src/changes/changes.xml
>>> @@ -31,6 +31,9 @@
>>>           - "remove" - Removed
>>>      -->
>>>      <release version="2.10.0" date="2017-MM-DD" description="GA Release
>>> 2.10.0">
>>> +      <action issue="LOG4J2-2087" dev="rpopma" type="fix" due-to="Andy
>>> Gumbrecht">
>>> +        Jansi now needs to be enabled explicitly (by setting system
>>> property `log4j.skipJansi` to `false`). To avoid causing problems for web
>>> applications, Log4j will no longer automatically try to load Jansi without
>>> explicit configuration.
>>> +      </action>
>>>        <action issue="LOG4J2-2060" dev="rpopma" type="fix">
>>>          AbstractDatabaseManager should make a copy of LogEvents before
>>> holding references to them: AsyncLogger log events are mutable.
>>>        </action>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
>>> 73efe3dc/src/site/xdoc/manual/layouts.xml.vm
>>> ----------------------------------------------------------------------
>>> diff --git a/src/site/xdoc/manual/layouts.xml.vm b/src/site/xdoc/manual/
>>> layouts.xml.vm
>>> index d878a2e..1e8cfb3 100644
>>> --- a/src/site/xdoc/manual/layouts.xml.vm
>>> +++ b/src/site/xdoc/manual/layouts.xml.vm
>>> @@ -912,17 +912,17 @@ WARN  [main]: Message 2</pre>
>>>                  <p>
>>>                    Specifying <code>%throwable{none}</code> or
>>> <code>%throwable{0}</code> suppresses output of the exception.
>>>                  </p>
>>> -                <p>
>>> -                  Use <code>filters(<i>packages</i>)</code>
where
>>> <i>packages</i> is a list of package names to
>>> +                <p>
>>> +                  Use <code>filters(<i>packages</i>)</code>
where
>>> <i>packages</i> is a list of package names to
>>>                    suppress matching stack frames from stack traces.
>>>                  </p>
>>>                  <p>
>>> -                  Use a <code>separator</code> string to separate
the
>>> lines of a stack trace. For example:
>>> -                  <code>separator(|)</code>. The default value is
the
>>> <code>line.separator</code> system property,
>>> +                  Use a <code>separator</code> string to separate
the
>>> lines of a stack trace. For example:
>>> +                  <code>separator(|)</code>. The default value is
the
>>> <code>line.separator</code> system property,
>>>                    which is operating system dependent.
>>>                  </p>
>>>                  <p>
>>> -                  Use <code>ex{suffix(<i>pattern</i>)</code>
to add the
>>> output of <i>pattern</i> to the output only
>>> +                  Use <code>ex{suffix(<i>pattern</i>)</code>
to add the
>>> output of <i>pattern</i> to the output only
>>>                    when there is a throwable to print.
>>>                  </p>
>>>                </td>
>>> @@ -944,6 +944,7 @@ WARN  [main]: Message 2</pre>
>>>                </td>
>>>                <td>
>>>                  <p>Adds ANSI colors to the result of the enclosed pattern
>>> based on the current event's logging level.
>>> +                   (See Jansi <a href="#enable-jansi">configuration</a>.)
>>>                  </p>
>>>                  <p>The default colors for each level are:
>>>                   <table>
>>> @@ -1164,7 +1165,8 @@ WARN  [main]: Message 2</pre>
>>>                  </p>
>>>                  <!-- Copied and tweaked from Javadoc for
>>> org.apache.logging.log4j.core.pattern.JAnsiMessageRenderer -->
>>>                  <p>
>>> -                  Add <code>{ansi}</code> to render messages with
ANSI
>>> escape codes (requires JAnsi.)
>>> +                  Add <code>{ansi}</code> to render messages with
ANSI
>>> escape codes (requires JAnsi,
>>> +                    see <a href="#enable-jansi">configuration</a>.)
>>>                  </p>
>>>                  <p>
>>>                    The default syntax for embedded ANSI codes is:
>>> @@ -1379,23 +1381,23 @@ WARN  [main]: Message 2</pre>
>>>                  </p>
>>>                  <p>
>>>                    The throwable conversion word can be followed by an
>>> option in the form
>>> -                  <code>%rEx{short}</code> which will only output
the
>>> first line of the Throwable or
>>> +                  <code>%rEx{short}</code> which will only output
the
>>> first line of the Throwable or
>>>                    <code>%rEx{n}</code> where the first n lines of
the
>>> stack trace will be printed.
>>>                  </p>
>>> -                <p>
>>> +                <p>
>>>                    Specifying <code>%rEx{none}</code> or
>>> <code>%rEx{0}</code> will suppress printing of the exception.
>>>                  </p>
>>> -                <p>
>>> -                  Use <code>filters(<i>packages</i>)</code>
where
>>> <i>packages</i> is a list of package names to
>>> +                <p>
>>> +                  Use <code>filters(<i>packages</i>)</code>
where
>>> <i>packages</i> is a list of package names to
>>>                    suppress matching stack frames from stack traces.
>>>                  </p>
>>>                  <p>
>>> -                  Use a <code>separator</code> string to separate
the
>>> lines of a stack trace. For example:
>>> -                  <code>separator(|)</code>. The default value is
the
>>> <code>line.separator</code> system property,
>>> +                  Use a <code>separator</code> string to separate
the
>>> lines of a stack trace. For example:
>>> +                  <code>separator(|)</code>. The default value is
the
>>> <code>line.separator</code> system property,
>>>                    which is operating system dependent.
>>>                  </p>
>>>                  <p>
>>> -                  Use <code>rEx{suffix(<i>pattern</i>)</code>
to add the
>>> output of <i>pattern</i> to the output only
>>> +                  Use <code>rEx{suffix(<i>pattern</i>)</code>
to add the
>>> output of <i>pattern</i> to the output only
>>>                    when there is a throwable to print.
>>>                  </p>
>>>                </td>
>>> @@ -1418,6 +1420,7 @@ WARN  [main]: Message 2</pre>
>>>                <td>
>>>                  <p>Uses ANSI escape sequences to style the result of the
>>> enclosed pattern. The style can consist of
>>>                    a comma separated list of style names from the
>>> following table.
>>> +                  (See Jansi <a href="#enable-jansi">configuration</a>.)
>>>                    <table>
>>>                      <tr>
>>>                        <th>Style Name</th>
>>> @@ -1645,17 +1648,18 @@ WARN  [main]: Message 2</pre>
>>>                    the first n lines of the stack trace will be printed.
>>> Specifying <code>%xEx{none}</code>
>>>                    or <code>%xEx{0}</code> will suppress printing
of the
>>> exception.
>>>                  </p>
>>> -                <p>
>>> -                  Use <code>filters(<i>packages</i>)</code>
where
>>> <i>packages</i> is a list of package names to
>>> +                <p>
>>> +                  Use <code>filters(<i>packages</i>)</code>
where
>>> <i>packages</i> is a list of package names to
>>>                    suppress matching stack frames from stack traces.
>>>                  </p>
>>>                  <p>
>>> -                  Use a <code>separator</code> string to separate
the
>>> lines of a stack trace. For example:
>>> -                  <code>separator(|)</code>. The default value is
the
>>> <code>line.separator</code> system property,
>>> +                  Use a <code>separator</code> string to separate
the
>>> lines of a stack trace. For example:
>>> +                  <code>separator(|)</code>. The default value is
the
>>> <code>line.separator</code> system property,
>>>                    which is operating system dependent.
>>>                  </p>
>>>                  <p>
>>>                   The <code>ansi</code> option renders stack traces
with
>>> ANSI escapes code using the JAnsi library.
>>> +                    (See <a href="#enable-jansi">configuration</a>.)
>>>                   Use <code>{ansi}</code> to use the default color
>>> mapping. You can specify your own mappings with
>>>                   <code>key=value</code> pairs. The keys are:
>>>                  </p>
>>> @@ -1821,11 +1825,17 @@ WARN  [main]: Message 2</pre>
>>>              </tr>
>>>              <caption align="top">Pattern Converters</caption>
>>>            </table>
>>> +          <a name="enable-jansi"></a>
>>>            <h4>ANSI Styling on Windows</h4>
>>>            <p>ANSI escape sequences are supported natively on many
>>> platforms but are not by default on Windows. To
>>> -            enable ANSI support simply add the <a href="
>>> http://jansi.fusesource.org/">Jansi</a> jar to your
>>> -            application and Log4j will automatically make use of it when
>>> writing to the console.
>>> +            enable ANSI support add the <a href="http://jansi.fusesource.
>>> org/">Jansi</a> jar to your application
>>> +            and set property <code>log4j.skipJansi</code> to
>>> <code>false</code>.
>>> +            This allows Log4j to use Jansi to add ANSI escape codes when
>>> writing to the console.
>>>            </p>
>>> +          <p>NOTE: Prior to Log4j 2.10, Jansi was enabled by default.
The
>>> fact that Jansi requires native code
>>> +              means that Jansi can only be loaded by a single class
>>> loader. For web applications this means the
>>> +              Jansi jar has to be in the web container's classpath. To
>>> avoid causing problems for web applications,
>>> +              Log4j will no longer automatically try to load Jansi
>>> without explicit configuration from Log4j 2.10 onward.</p>
>>>            <h4>Example Patterns</h4>
>>>            <h5>Filtered Throwables</h5>
>>>            <p>This example shows how to filter out classes from
>>> unimportant packages in stack traces.
>>>
>>>
>>
>>
>> -- 
>> Matt Sicker <boards@gmail.com>
> 



Mime
View raw message