You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2017/07/30 10:34:18 UTC
[1/2] logging-log4j2 git commit: LOG4J2-1990 refactor
#logMessageSafely method to stay within 35 byte MaxInlineSize threshold;
add TODO for Configuration setting to propagate exceptions back to caller
Repository: logging-log4j2
Updated Branches:
refs/heads/master 41d9ac07d -> b79d6c5d7
LOG4J2-1990 refactor #logMessageSafely method to stay within 35 byte MaxInlineSize threshold; add TODO for Configuration setting to propagate exceptions back to caller
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/218117a9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/218117a9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/218117a9
Branch: refs/heads/master
Commit: 218117a910995918b75ba718076e4b08862245a9
Parents: 68de0ff
Author: rpopma <rp...@apache.org>
Authored: Sun Jul 30 19:33:40 2017 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sun Jul 30 19:33:40 2017 +0900
----------------------------------------------------------------------
.../logging/log4j/spi/AbstractLogger.java | 53 +++++++++++++++-----
1 file changed, 41 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/218117a9/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
index 949c1b9..18e1b80 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
@@ -37,6 +37,7 @@ import org.apache.logging.log4j.util.Constants;
import org.apache.logging.log4j.util.LambdaUtil;
import org.apache.logging.log4j.util.LoaderUtil;
import org.apache.logging.log4j.util.MessageSupplier;
+import org.apache.logging.log4j.util.PerformanceSensitive;
import org.apache.logging.log4j.util.PropertiesUtil;
import org.apache.logging.log4j.util.Strings;
import org.apache.logging.log4j.util.Supplier;
@@ -45,6 +46,10 @@ import org.apache.logging.log4j.util.Supplier;
* Base implementation of a Logger. It is highly recommended that any Logger implementation extend this class.
*/
public abstract class AbstractLogger implements ExtendedLogger, Serializable {
+ // Implementation note: many methods in this class are tuned for performance. MODIFY WITH CARE!
+ // Specifically, try to keep the hot methods to 35 bytecodes or less:
+ // this is within the MaxInlineSize threshold and makes these methods candidates for
+ // immediate inlining instead of waiting until they are designated "hot enough".
/**
* Marker for flow tracing.
@@ -2085,27 +2090,51 @@ public abstract class AbstractLogger implements ExtendedLogger, Serializable {
}
}
+ @PerformanceSensitive
+ // NOTE: This is a hot method. Current implementation compiles to 30 bytes of byte code.
+ // This is within the 35 byte MaxInlineSize threshold. Modify with care!
private void logMessageSafely(final String fqcn, final Level level, final Marker marker, final Message msg,
final Throwable throwable) {
try {
- logMessage(fqcn, level, marker, msg, throwable);
- } catch (Exception e) {
- final String format = msg.getFormat();
- final StringBuilder sb = new StringBuilder(format.length() + 100);
- sb.append(fqcn);
- sb.append(": ");
- sb.append(e.getClass().getName());
- sb.append(" logging a ");
- sb.append(msg.getClass().getSimpleName());
- sb.append(": ");
- sb.append(format);
- StatusLogger.getLogger().warn(sb.toString(), e);
+ tryLogMessage(fqcn, level, marker, msg, throwable);
} finally {
// LOG4J2-1583 prevent scrambled logs when logging calls are nested (logging in toString())
ReusableMessageFactory.release(msg);
}
}
+ @PerformanceSensitive
+ // NOTE: This is a hot method. Current implementation compiles to 26 bytes of byte code.
+ // This is within the 35 byte MaxInlineSize threshold. Modify with care!
+ private void tryLogMessage(final String fqcn,
+ final Level level,
+ final Marker marker,
+ final Message msg,
+ final Throwable throwable) {
+ try {
+ logMessage(fqcn, level, marker, msg, throwable);
+ } catch (final Exception e) {
+
+ // LOG4J2-1990 Log4j2 suppresses all exceptions that occur once application called the logger
+ handleLogMessageException(e, fqcn, msg);
+ }
+ }
+
+ // LOG4J2-1990 Log4j2 suppresses all exceptions that occur once application called the logger
+ // TODO Configuration setting to propagate exceptions back to the caller *if requested*
+ private void handleLogMessageException(final Exception exception, final String fqcn, final Message msg) {
+ final String format = msg.getFormat();
+ final StringBuilder sb = new StringBuilder(format.length() + 100);
+ sb.append(fqcn);
+ sb.append(": ");
+ sb.append(exception.getClass().getName());
+ sb.append(" logging a ");
+ sb.append(msg.getClass().getSimpleName());
+ sb.append(": ");
+ sb.append(format);
+ StatusLogger.getLogger().warn(sb.toString(), exception);
+ }
+
@Override
public <T extends Throwable> T throwing(final T t) {
return throwing(FQCN, Level.ERROR, t);
[2/2] logging-log4j2 git commit: Merge remote-tracking branch
'origin/master'
Posted by rp...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b79d6c5d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b79d6c5d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b79d6c5d
Branch: refs/heads/master
Commit: b79d6c5d7b6663c38b07ce88f924efe7419b9455
Parents: 218117a 41d9ac0
Author: rpopma <rp...@apache.org>
Authored: Sun Jul 30 19:34:06 2017 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sun Jul 30 19:34:06 2017 +0900
----------------------------------------------------------------------
log4j-api-scala_2.10/pom.xml | 157 -----
.../org/apache/logging/log4j/scala/Logger.scala | 592 -------------------
.../logging/log4j/scala/LoggerMacro.scala | 425 -------------
.../apache/logging/log4j/scala/Logging.scala | 30 -
.../apache/logging/log4j/scala/LoggerTest.scala | 552 -----------------
log4j-api-scala_2.11/pom.xml | 157 -----
.../org/apache/logging/log4j/scala/Logger.scala | 592 -------------------
.../logging/log4j/scala/LoggerMacro.scala | 425 -------------
.../apache/logging/log4j/scala/Logging.scala | 30 -
.../apache/logging/log4j/scala/LoggerTest.scala | 552 -----------------
log4j-bom/pom.xml | 12 -
log4j-distribution/pom.xml | 22 -
log4j-samples/pom.xml | 1 -
log4j-samples/scala-api/.gitignore | 3 -
log4j-samples/scala-api/pom.xml | 88 ---
.../scala-api/src/main/resources/log4j2.xml | 32 -
.../logging/log4j/scalasample/LoggingApp.scala | 47 --
pom.xml | 12 -
src/site/markdown/javadoc.md | 2 +-
src/site/markdown/maven-artifacts.md.vm | 7 +
src/site/site.xml | 4 +-
src/site/xdoc/manual/scala-api.xml | 6 +-
src/site/xdoc/runtime-dependencies.xml | 2 +-
23 files changed, 13 insertions(+), 3737 deletions(-)
----------------------------------------------------------------------