/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache license, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the license for the specific language governing permissions and
 * limitations under the license.
 */
package org.apache.logging.log4j.core.appender;

import java.io.IOException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;

/**
 * Shows how to use ANSI escape codes to color messages. Each message is printed to the console in color, but the rest
 * of the log entry (time stamp for example) is in the default color for that console.
 * <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.11\jansi-1.11.jar; org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleLayoutMain log4j-core/target/test-classes/log4j2-console-style-ansi.xml
 * </pre>
 */
public class ConsoleAppenderAnsiStyleLayoutMain {

    private static final Logger LOG = LogManager.getLogger(ConsoleAppenderAnsiStyleLayoutMain.class);

    public static void main(final String[] args) {
        // System.out.println(System.getProperty("java.class.path"));
        final String config = args.length == 0 ? "target/test-classes/log4j2-console-style-ansi.xml" : args[0];
        final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config);
        try {
            LOG.fatal("Fatal message.");
            LOG.error("Error message.");
            LOG.warn("Warning message.");
            LOG.info("Information message.");
            LOG.debug("Debug message.");
            LOG.trace("Trace message.");
            LOG.error("Error message.", new IOException("test"));
        } finally {
            Configurator.shutdown(ctx);
        }
    }

}

@@ -1065,16 +1065,39 @@
 gurator;
+%0Aimport org.junit.Test;
 %0A%0A/**%0A *
@@ -1386,17 +1386,135 @@
  %3C/p%3E%0A *
- 
+%0A * %3Cpre%3E%0A * mvn -Dtest=org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleLayoutMain test%0A * %3C/pre%3E%0A * or:
 %0A * %3Cpre
@@ -1831,16 +1831,20 @@
  %3C/pre%3E%0A
+ * %0A
  */%0Apubl
@@ -1899,22 +1899,21 @@
    p
-rivate
+ublic
  static 
 fina
@@ -1912,115 +1912,310 @@
 tic 
-final Logger LOG = LogManager.getLogger(ConsoleAppenderAnsiStyleLayoutMain.class);%0A%0A    public stat
+void main(final String%5B%5D args) %7B%0A        new ConsoleAppenderAnsiStyleLayoutMain().test(args);%0A    %7D%0A%0A    /**%0A     * This is a @Test method to make it easy to run from a command line with %7B@code mvn -Dtest=FQCN test%7D%0A     */%0A    @Test%0A    public void test() %7B%0A        test(null);%0A    %7D%0A%0A    publ
 ic void 
 main
@@ -2202,36 +2202,36 @@
     public void 
-main
+test
 (final String%5B%5D 
@@ -2337,16 +2337,32 @@
 config =
+ args == null %7C%7C
  args.le
@@ -2424,16 +2424,32 @@
 nsi.xml%22
+%0A               
  : args%5B
@@ -2568,16 +2568,110 @@
 onfig);%0A
+        final Logger logger = LogManager.getLogger(ConsoleAppenderAnsiStyleLayoutMain.class);%0A
         
@@ -2688,19 +2688,22 @@
         
-LOG
+logger
 .fatal(%22
@@ -2724,35 +2724,38 @@
 %22);%0A            
-LOG
+logger
 .error(%22Error me
@@ -2776,19 +2776,22 @@
         
-LOG
+logger
 .warn(%22W
@@ -2821,19 +2821,22 @@
         
-LOG
+logger
 .info(%22I
@@ -2870,19 +2870,22 @@
         
-LOG
+logger
 .debug(%22
@@ -2914,19 +2914,22 @@
         
-LOG
+logger
 .trace(%22
@@ -2962,11 +2962,14 @@
     
-LOG
+logger
 .err

Make it easy to run from a command line with 'mvn -Dtest=FQCN test'