Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVioleta Georgieva2013-04-18 15:40:07 -0400
committerVioleta Georgieva2013-04-18 15:40:07 -0400
commitfaa92db872262e5782df666f879473c9a53f1d58 (patch)
tree41045db128c6c0c0e2a6f1e6a31cea0de1579511
parent4a49f3c44a6d770d9128635a9650c5631674a9ed (diff)
downloadorg.eclipse.virgo.medic-faa92db872262e5782df666f879473c9a53f1d58.tar.gz
org.eclipse.virgo.medic-faa92db872262e5782df666f879473c9a53f1d58.tar.xz
org.eclipse.virgo.medic-faa92db872262e5782df666f879473c9a53f1d58.zip
bug 406027: Do not initialize the logger during o.e.v.medic.log.impl.LoggingPrintStreamWrapper construction phase.
-rw-r--r--org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/log/impl/LoggingPrintStreamWrapper.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/log/impl/LoggingPrintStreamWrapper.java b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/log/impl/LoggingPrintStreamWrapper.java
index 62c0383..e97cd0b 100644
--- a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/log/impl/LoggingPrintStreamWrapper.java
+++ b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/log/impl/LoggingPrintStreamWrapper.java
@@ -42,7 +42,7 @@ public final class LoggingPrintStreamWrapper extends PrintStream {
private final ThreadLocal<StringBuilder> entryBuilders;
- private final Logger logger;
+ private Logger logger;
private final ExecutionStackAccessor executionStackAccessor;
@@ -53,7 +53,9 @@ public final class LoggingPrintStreamWrapper extends PrintStream {
private final PrintStream originalPrintStream;
private final LoggingLevel loggingLevel;
-
+
+ private final String loggerName;
+
private static final String NULL_STRING = "null";
/**
@@ -71,7 +73,7 @@ public final class LoggingPrintStreamWrapper extends PrintStream {
public LoggingPrintStreamWrapper(PrintStream printStream, String loggerName, LoggingLevel loggingLevel, ExecutionStackAccessor executionStackAccessor, ConfigurationProvider configurationProvider, String configurationProperty) {
super(printStream);
- this.logger = LoggerFactory.getLogger(loggerName);
+ this.loggerName = loggerName;
this.loggingLevel = loggingLevel;
this.executionStackAccessor = executionStackAccessor;
@@ -149,7 +151,7 @@ public final class LoggingPrintStreamWrapper extends PrintStream {
super.append(csq);
} else {
if(csq == null){
- throw new NullPointerException("Character Sequence to be added to the printStream from source '" + this.logger.getName() + "' is null");
+ throw new NullPointerException("Character Sequence to be added to the printStream from source '" + this.loggerName + "' is null");
}
this.internalAppend(csq, 0, csq.length());
}
@@ -472,10 +474,10 @@ public final class LoggingPrintStreamWrapper extends PrintStream {
private void createEntryAndLog(final StringBuilder stringBuilder) {
final String string = stringBuilder.toString();
switch (this.loggingLevel) {
- case DEBUG: this.logger.debug(string); break;
- case ERROR: this.logger.error(string); break;
- case INFO: this.logger.info(string); break;
- case WARNING: this.logger.warn(string); break;
+ case DEBUG: getLogger().debug(string); break;
+ case ERROR: getLogger().error(string); break;
+ case INFO: getLogger().info(string); break;
+ case WARNING: getLogger().warn(string); break;
}
entryBuilders.remove();
}
@@ -507,4 +509,11 @@ public final class LoggingPrintStreamWrapper extends PrintStream {
public PrintStream getOriginalPrintStream() {
return this.originalPrintStream;
}
+
+ private Logger getLogger() {
+ if (this.logger == null) {
+ this.logger = LoggerFactory.getLogger(this.loggerName);
+ }
+ return this.logger;
+ }
}

Back to the top