logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1612992 - in /logging/log4j/log4j2/trunk/log4j-core/src/test: java/org/apache/logging/log4j/core/appender/Jira739Test.java resources/LOG4J2-739.xml
Date Thu, 24 Jul 2014 04:46:06 GMT
Author: ggregory
Date: Thu Jul 24 04:46:05 2014
New Revision: 1612992

URL: http://svn.apache.org/r1612992
Log:
Test https://issues.apache.org/jira/browse/LOG4J2-739 but not as a unit test.

Added:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
  (with props)
    logging/log4j/log4j2/trunk/log4j-core/src/test/resources/LOG4J2-739.xml   (with props)

Added: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java?rev=1612992&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
(added)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
Thu Jul 24 04:46:05 2014
@@ -0,0 +1,55 @@
+/*
+ * 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.ConsoleAppenderAnsiMessagesMain log4j-core/target/test-classes/log4j2-console.xml
+ * </pre>
+ */
+public class Jira739Test {
+
+    private static final Logger LOG = LogManager.getLogger(Jira739Test.class);
+
+    public static void main(final String[] args) {
+        final LoggerContext ctx = Configurator.initialize(Jira739Test.class.getName(),
+                "target/test-classes/LOG4J2-739.xml");
+        try {
+            for (int i = 0; i < 10; i++) {
+                LOG.trace("Entering Log4j Example " + i + " times");
+                LOG.error("Ohh!Failed!");
+                LOG.trace("Exiting Log4j Example." + i + " times");
+            }
+        } finally {
+            Configurator.shutdown(ctx);
+        }
+    }
+
+}

Propchange: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/Jira739Test.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: logging/log4j/log4j2/trunk/log4j-core/src/test/resources/LOG4J2-739.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/resources/LOG4J2-739.xml?rev=1612992&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/resources/LOG4J2-739.xml (added)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/resources/LOG4J2-739.xml Thu Jul 24 04:46:05
2014
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>  
+<Configuration status="trace"> 
+    <properties>		
+        <property name="name">app</property>
+        <property name="pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5.5p | %-10.10t |
%-20.20C:%-5.5L | %msg%n</property>
+    </properties>
+     <Appenders>  
+         <Console name="CONSOLE" target="SYSTEM_OUT">  
+             <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
/>  
+         </Console>
+        <RollingFile name="RollingFile" fileName="logs/${name}.log" filePattern="logs/$${date:yyyy-MM}/${name}-%d{yyyy-MM-dd}-%i.log.gz">
+            <XMLLayout complete="true" />
+            <Policies>
+                <SizeBasedTriggeringPolicy size="100"/> 
+            </Policies>
+        </RollingFile>       
+     </Appenders>  
+     <Loggers>  
+         <Root level="error">  
+             <AppenderRef ref="Console" />  
+        </Root>
+         <logger name="log4j2poc.Log4J2Example" level="TRACE" />  
+         <Root level="ERROR">  
+             <AppenderRef ref="CONSOLE"/>  
+             <AppenderRef ref="RollingFile" /> 
+         </Root>  
+     </Loggers>  
+ </Configuration> 
\ No newline at end of file

Propchange: logging/log4j/log4j2/trunk/log4j-core/src/test/resources/LOG4J2-739.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/log4j2/trunk/log4j-core/src/test/resources/LOG4J2-739.xml
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message