You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2013/08/23 06:24:42 UTC
svn commit: r1516697 - in /logging/log4j/log4j2/trunk:
core/src/main/java/org/apache/logging/log4j/core/pattern/
core/src/test/java/org/apache/logging/log4j/core/appender/
core/src/test/resources/ src/changes/
Author: ggregory
Date: Fri Aug 23 04:24:42 2013
New Revision: 1516697
URL: http://svn.apache.org/r1516697
Log:
[LOG4J2-319] Double stack trace logging when using %throwable in a %style.
Modified:
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/PatternFormatter.java
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/StyleConverter.java
logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java
logging/log4j/log4j2/trunk/core/src/test/resources/log4j2-console-style-ansi.xml
logging/log4j/log4j2/trunk/src/changes/changes.xml
Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/PatternFormatter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/PatternFormatter.java?rev=1516697&r1=1516696&r2=1516697&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/PatternFormatter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/PatternFormatter.java Fri Aug 23 04:24:42 2013
@@ -46,6 +46,19 @@ public class PatternFormatter {
}
/**
+ * Normally pattern formatters are not meant to handle Exceptions although
+ * few pattern formatters might.
+ * <p/>
+ * By examining the return values for this method, the containing layout will
+ * determine whether it handles throwables or not.
+ *
+ * @return true if this PatternConverter handles throwables
+ */
+ public boolean handlesThrowable() {
+ return converter.handlesThrowable();
+ }
+
+ /**
* Returns a String suitable for debugging.
*
* @return a String suitable for debugging.
Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/StyleConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/StyleConverter.java?rev=1516697&r1=1516696&r2=1516697&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/StyleConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/pattern/StyleConverter.java Fri Aug 23 04:24:42 2013
@@ -89,6 +89,16 @@ public final class StyleConverter extend
}
}
+ @Override
+ public boolean handlesThrowable() {
+ for (final PatternFormatter formatter : patternFormatters) {
+ if (formatter .handlesThrowable()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Returns a String suitable for debugging.
*
Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java?rev=1516697&r1=1516696&r2=1516697&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java Fri Aug 23 04:24:42 2013
@@ -24,16 +24,24 @@ import org.apache.logging.log4j.core.Log
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.
+ * 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 core\target\test-classes;core\target\classes;api\target\classes;%HOME%\.m2\repository\org\fusesource\jansi\jansi\1.11\jansi-1.11.jar; org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleLayoutMain 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) {
- final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
- "target/test-classes/log4j2-console-style-ansi.xml");
+ // System.out.println(System.getProperty("java.class.path"));
+ 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.");
Modified: logging/log4j/log4j2/trunk/core/src/test/resources/log4j2-console-style-ansi.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/log4j2-console-style-ansi.xml?rev=1516697&r1=1516696&r2=1516697&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/log4j2-console-style-ansi.xml (original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/log4j2-console-style-ansi.xml Fri Aug 23 04:24:42 2013
@@ -16,7 +16,7 @@
limitations under the License.
-->
-<Configuration status="OFF">
+<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%style{%d{ISO8601}}{black} %style{[%t]}{blue} %style{%-5level:}{yellow} %style{%msg%n%throwable}{green}" />
Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1516697&r1=1516696&r2=1516697&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Fri Aug 23 04:24:42 2013
@@ -21,6 +21,9 @@
</properties>
<body>
<release version="2.0-beta9" date="soon, very soon" description="Bug fixes and enhancements">
+ <action issue="LOG4J2-319" dev="ggregory" type="update">
+ Double stack trace logging when using %throwable in a %style.
+ </action>
<action issue="LOG4J2-366" dev="ggregory" type="update">
Update commons-logging to 1.1.3 from 1.1.1.
</action>