logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r821436 - in /logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge: JULBridgeHandler.java JULLog4jEventConverter.java
Date Sat, 03 Oct 2009 22:32:31 GMT
Author: sdeboy
Date: Sat Oct  3 22:32:31 2009
New Revision: 821436

URL: http://svn.apache.org/viewvc?rev=821436&view=rev
Log:
Applying patch provided by Adrian Stanila for  Bug 47912 -  Jul to log4j bridge Crash - thanks
Adrian

Modified:
    logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeHandler.java
    logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULLog4jEventConverter.java

Modified: logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeHandler.java
URL: http://svn.apache.org/viewvc/logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeHandler.java?rev=821436&r1=821435&r2=821436&view=diff
==============================================================================
--- logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeHandler.java
(original)
+++ logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULBridgeHandler.java
Sat Oct  3 22:32:31 2009
@@ -27,6 +27,7 @@
  * 
  */
 class JULBridgeHandler extends Handler {
+    private static final String UNKNOWN_LOGGER_NAME = "unknown.jul.logger";
 
     private final LoggerRepository repository;
     private final JULLog4jEventConverter converter;
@@ -48,7 +49,12 @@
     public void publish(LogRecord record) {
         LoggingEvent event = converter.convert(record);
 
-        Category localLogger = repository.getLogger(record.getLoggerName());
+        String loggerName = record.getLoggerName();
+        if (loggerName == null) {
+    	    loggerName = UNKNOWN_LOGGER_NAME;
+        }
+
+        Category localLogger = repository.getLogger(loggerName);
         if (event.getLevel().isGreaterOrEqual(localLogger.getEffectiveLevel())) {
             localLogger.callAppenders(event);
         }

Modified: logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULLog4jEventConverter.java
URL: http://svn.apache.org/viewvc/logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULLog4jEventConverter.java?rev=821436&r1=821435&r2=821436&view=diff
==============================================================================
--- logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULLog4jEventConverter.java
(original)
+++ logging/sandbox/jul-to-log4j-bridge/src/main/java/org/apache/logging/julbridge/JULLog4jEventConverter.java
Sat Oct  3 22:32:31 2009
@@ -27,6 +27,7 @@
  * @author psmith
  */
 public class JULLog4jEventConverter {
+private static final String UNKNOWN_LOGGER_NAME = "unknown.jul.logger";
 
     /**
      * A default implementation of a converter that converts:
@@ -118,6 +119,9 @@
      */
     public LoggingEvent convert(LogRecord record) {
         String loggerName = record.getLoggerName();
+        if (loggerName == null) {
+    	    loggerName = UNKNOWN_LOGGER_NAME;
+        }
         Logger logger = repository.getLogger(loggerName);
         String sourceClassName = record.getSourceClassName();
         String sourceMethodName = record.getSourceMethodName();



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message