Index: src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java =================================================================== --- src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java (revision 1629) +++ src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java (working copy) @@ -10,20 +10,19 @@ package ch.qos.logback.classic.spi; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import org.slf4j.MDC; +import org.slf4j.Marker; +import org.slf4j.helpers.MessageFormatter; +import org.slf4j.impl.LogbackMDCAdapter; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Map; -import org.slf4j.MDC; -import org.slf4j.Marker; -import org.slf4j.helpers.MessageFormatter; -import org.slf4j.impl.LogbackMDCAdapter; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; - /** * The internal representation of logging events. When an affirmative decision * is made to log then a LoggingEvent instance is created. This @@ -113,12 +112,16 @@ // bug 85 (we previously failed to set this.argumentArray) this.argumentArray = argArray; - - if (argArray != null) { - formattedMessage = MessageFormatter.arrayFormat(message, argArray); + + // formattedMessage is initialized lazily in getFormattedMessage + /* + if (argumentArray != null) { + formattedMessage = MessageFormatter.arrayFormat(message, argumentArray); } else { formattedMessage = message; } + */ + timeStamp = System.currentTimeMillis(); // the case is ugly but under the circumstances acceptable @@ -236,7 +239,7 @@ * * @return The time as measured when this class was loaded into memory. */ - public static final long getStartTime() { + public static long getStartTime() { return startTime; } @@ -276,6 +279,13 @@ } public String getFormattedMessage() { + if(formattedMessage == null) { + if (argumentArray != null) { + formattedMessage = MessageFormatter.arrayFormat(message, argumentArray); + } else { + formattedMessage = message; + } + } return formattedMessage; } @@ -284,6 +294,17 @@ } private void writeObject(ObjectOutputStream out) throws IOException { + // fix for bug #100 & bug #118 + if(argumentArray!=null) { + for(int i=0;i