Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 
 package ch.qos.logback.classic.spi;
 
 import java.util.Map;
 
 import org.slf4j.MDC;
 
The internal representation of logging events. When an affirmative decision is made to log then a LoggingEvent instance is created. This instance is passed around to the different logback-classic components.

Writers of logback-classic components such as appenders should be aware of that some of the LoggingEvent fields are initialized lazily. Therefore, an appender wishing to output data to be later correctly read by a receiver, must initialize "lazy" fields prior to writing them out. See the prepareForDeferredProcessing() method for the exact list.

Author(s):
Ceki Gülcü
Sébastien Pennec
 
 public class LoggingEvent implements ILoggingEvent {

  
Fully qualified name of the calling Logger class. This field does not survive serialization.

Note that the getCallerInformation() method relies on this fact.

 
   transient String fqnOfLoggerClass;

  
The name of thread in which this logging event was generated.
 
   private String threadName;
 
   private String loggerName;
   private LoggerContextVO loggerContextVO;

  
Level of logging event.

This field should not be accessed directly. You should use the getLevel() method instead.

 
   private transient Level level;
 
   private String message;
 
   // we gain significant space at serialization time by marking
   // formattedMessage as transient and constructing it lazily in
   // getFormattedMessage()
   private transient String formattedMessage;
 
   private transient Object[] argumentArray;
 
 
 
   private Marker marker;
 
   private Map<StringStringmdcPropertyMap;
   private static final Map<StringStringCACHED_NULL_MAP = new HashMap<StringString>();

  
The number of milliseconds elapsed from 1/1/1970 until logging event was created.
 
   private long timeStamp;
 
  public LoggingEvent() {
  }
  public LoggingEvent(String fqcnLogger loggerLevel levelString message,
                      Throwable throwableObject[] argArray) {
    this. = fqcn;
    this. = logger.getName();
    this. = logger.getLoggerContext();
    this. = level;
    this. = message;
    FormattingTuple ft = MessageFormatter.arrayFormat(messageargArray);
    if (throwable == null) {
       = ft.getArgArray();
      throwable = ft.getThrowable();
    } else {
      this. = argArray;
    }
    if (throwable != null) {
      this. = new ThrowableProxy(throwable);
      LoggerContext lc = logger.getLoggerContext();
      if (lc.isPackagingDataEnabled()) {
      }
    }
     = System.currentTimeMillis();
  }
  public void setArgumentArray(Object[] argArray) {
    if (this. != null) {
      throw new IllegalStateException("argArray has been already set");
    }
    this. = argArray;
  }
  public Object[] getArgumentArray() {
    return this.;
  }
  public Level getLevel() {
    return ;
  }
  public String getLoggerName() {
    return ;
  }
  public void setLoggerName(String loggerName) {
    this. = loggerName;
  }
  public String getThreadName() {
    if ( == null) {
       = (Thread.currentThread()).getName();
    }
    return ;
  }

  

Parameters:
threadName The threadName to set.
Throws:
java.lang.IllegalStateException If threadName has been already set.
  public void setThreadName(String threadNamethrows IllegalStateException {
    if (this. != null) {
      throw new IllegalStateException("threadName has been already set");
    }
    this. = threadName;
  }

  
Returns the throwable information contained within this event. May be null if there is no such information.
    return ;
  }

  
Set this event's throwable information.
  public void setThrowableProxy(ThrowableProxy tp) {
    if ( != null) {
      throw new IllegalStateException("ThrowableProxy has been already set.");
    } else {
       = tp;
    }
  }

  
This method should be called prior to serializing an event. It should also be called when using asynchronous or deferred logging.

Note that due to performance concerns, this method does NOT extract caller data. It is the responsibility of the caller to extract caller information.

  public void prepareForDeferredProcessing() {
    this.getFormattedMessage();
    this.getThreadName();
    // fixes http://jira.qos.ch/browse/LBCLASSIC-104
    this.getMDCPropertyMap();
  }
    return ;
  }
  public void setLoggerContextRemoteView(LoggerContextVO loggerContextVO) {
    this. = loggerContextVO;
  }
  public String getMessage() {
    return ;
  }
  public void setMessage(String message) {
    if (this. != null) {
      throw new IllegalStateException(
              "The message for this event has been set already.");
    }
    this. = message;
  }
  public long getTimeStamp() {
    return ;
  }
  public void setTimeStamp(long timeStamp) {
    this. = timeStamp;
  }
  public void setLevel(Level level) {
    if (this. != null) {
      throw new IllegalStateException(
              "The level has been already set for this event.");
    }
    this. = level;
  }

  
Get the caller information for this logging event. If caller information is null at the time of its invocation, this method extracts location information. The collected information is cached for future use.

Note that after serialization it is impossible to correctly extract caller information.

    if ( == null) {
       = CallerData.extract(new Throwable(), ,
    }
    return ;
  }
  public boolean hasCallerData() {
    return ( != null);
  }
  public void setCallerData(StackTraceElement[] callerDataArray) {
    this. = callerDataArray;
  }
  public Marker getMarker() {
    return ;
  }
  public void setMarker(Marker marker) {
    if (this. != null) {
      throw new IllegalStateException(
              "The marker has been already set for this event.");
    }
    this. = marker;
  }
  public long getContextBirthTime() {
    return .getBirthTime();
  }
  // computer formatted lazy as suggested in
  // http://jira.qos.ch/browse/LBCLASSIC-47
  public String getFormattedMessage() {
    if ( != null) {
      return ;
    }
    if ( != null) {
       = MessageFormatter.arrayFormat()
              .getMessage();
    } else {
       = ;
    }
    return ;
  }
  public Map<StringStringgetMDCPropertyMap() {
    // populate mdcPropertyMap if null
    if ( == null) {
      MDCAdapter mdc = MDC.getMDCAdapter();
      if (mdc instanceof LogbackMDCAdapter)
         = ((LogbackMDCAdaptermdc).getPropertyMap();
      else
         = mdc.getCopyOfContextMap();
    }
    // mdcPropertyMap still null, use CACHED_NULL_MAP
    if ( == null)
    return ;
  }

  
Set the MDC map for this event.

Parameters:
map
Since:
1.0.8
  public void setMDCPropertyMap(Map<StringStringmap) {
    if ( != null) {
      throw new IllegalStateException(
              "The MDCPropertyMap has been already set for this event.");
    }
    this. = map;
  }

  
Synonym for [@link #getMDCPropertyMap}.

Deprecated:
Replaced by [@link .getMDCPropertyMap}
  public Map<StringStringgetMdc() {
    return getMDCPropertyMap();
  }
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append('[');
    sb.append().append("] ");
    return sb.toString();
  }
New to GrepCode? Check out our FAQ X