Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvladt2011-02-16 17:30:16 -0500
committervladt2011-02-16 17:30:16 -0500
commit2750124b49f7d8688d280197655984adde027983 (patch)
tree44801ea9d239a085e64e70f031e6369526f179c8
parentd9acacd40006bf9c6168f8e59d218f4535435c9f (diff)
downloadm2e-core-2750124b49f7d8688d280197655984adde027983.tar.gz
m2e-core-2750124b49f7d8688d280197655984adde027983.tar.xz
m2e-core-2750124b49f7d8688d280197655984adde027983.zip
337348: NPE in logging on eclipse 3.7
-rw-r--r--org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/EclipseLogAppender.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/EclipseLogAppender.java b/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/EclipseLogAppender.java
index ce40c7d1..61ed0980 100644
--- a/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/EclipseLogAppender.java
+++ b/org.eclipse.m2e.logback.appender/src/main/java/org/eclipse/m2e/logback/appender/EclipseLogAppender.java
@@ -11,6 +11,8 @@
package org.eclipse.m2e.logback.appender;
+import org.osgi.framework.Bundle;
+
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
@@ -22,7 +24,7 @@ import org.eclipse.core.runtime.Status;
public class EclipseLogAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
- private static final String ID = "org.eclipse.m2e.logback.appender.EclipseLogAppender"; //$NON-NLS-1$
+ private static final String BUNDLE_ID = "org.eclipse.m2e.logback.appender"; //$NON-NLS-1$
@Override
protected void append(ILoggingEvent logEvent) {
@@ -41,11 +43,20 @@ public class EclipseLogAppender extends UnsynchronizedAppenderBase<ILoggingEvent
return;
}
- IStatus status = new Status(severity, ID, logEvent.getFormattedMessage(), getThrowable(logEvent));
- ILog eclipseLog = Platform.getLog(null);
+ IStatus status = new Status(severity, BUNDLE_ID, logEvent.getFormattedMessage(), getThrowable(logEvent));
+ ILog eclipseLog = Platform.getLog(getSelfBundle());
eclipseLog.log(status);
}
+ private Bundle self;
+
+ private Bundle getSelfBundle() {
+ if(self == null) {
+ self = Platform.getBundle(BUNDLE_ID);
+ }
+ return self;
+ }
+
private Throwable getThrowable(ILoggingEvent logEvent) {
Object[] args = logEvent.getArgumentArray();
if(args == null || args.length == 0) {

Back to the top