Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVioleta Georgieva2013-04-18 15:40:07 -0400
committerVioleta Georgieva2013-04-18 15:40:57 -0400
commitecd64fd2f658cdb675a00a367fae4178f6b00cea (patch)
tree3d6ad77affb2f9fad7c3da3adc8603a17a5aa082
parentc06a048f5fad46e8ca0d29c5e616ba6331b270e3 (diff)
downloadorg.eclipse.virgo.medic-ecd64fd2f658cdb675a00a367fae4178f6b00cea.tar.gz
org.eclipse.virgo.medic-ecd64fd2f658cdb675a00a367fae4178f6b00cea.tar.xz
org.eclipse.virgo.medic-ecd64fd2f658cdb675a00a367fae4178f6b00cea.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