ch.qos.logback.contrib.eclipse
Class EclipseLogAppender

java.lang.Object
  extended by ch.qos.logback.core.spi.ContextAwareBase
      extended by ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
          extended by ch.qos.logback.contrib.eclipse.EclipseLogAppender
All Implemented Interfaces:
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.LifeCycle

public class EclipseLogAppender
extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>

An appender that wraps the Eclipse platform logging facility and redirects messages to Eclipse's Error Log. Sample logback configuration:

 <configuration>
    <appender name="eclipse" class="ch.qos.logback.contrib.EclipseLogAppender">
        <encoder>
            <pattern>[%method] > %msg%n</pattern>
        </encoder>
        
        <!-- optional: bundle whose logger will be used for displaying messages -->
        <bundleName>com.example.e4.helloworld</bundleName>
    </appender>

    <root level="TRACE">
        <appender-ref ref="eclipse" />
    </root>
 </configuration>
 

Author:
Anthony Trinh

Field Summary
static String DEFAULT_BUNDLE_SYMBOLIC_NAME
           
 
Fields inherited from class ch.qos.logback.core.AppenderBase
name, started
 
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
 
Constructor Summary
EclipseLogAppender()
           
 
Method Summary
protected  void append(ch.qos.logback.classic.spi.ILoggingEvent event)
          Writes an event to Eclipse's Error Log
 String getBundleName()
          Gets the symbolic name of the Eclipse plugin bundle whose logger is used for logging messages
 ch.qos.logback.classic.encoder.PatternLayoutEncoder getEncoder()
          Gets the pattern-layout encoder for this appender's log message
protected  IPlatform getPlatform()
          Gets the Eclipse platform
 void setBundleName(String bundleName)
          Sets the name of the Eclipse plugin bundle whose logger will be used for logging messages.
 void setEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder encoder)
          Sets the pattern-layout encoder for this appender's log message
 void start()
          Checks that required parameters are set, and if everything is in order, activates this appender.
 
Methods inherited from class ch.qos.logback.core.AppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, stop, toString
 
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
 

Field Detail

DEFAULT_BUNDLE_SYMBOLIC_NAME

public static final String DEFAULT_BUNDLE_SYMBOLIC_NAME
See Also:
Constant Field Values
Constructor Detail

EclipseLogAppender

public EclipseLogAppender()
Method Detail

start

public void start()
Checks that required parameters are set, and if everything is in order, activates this appender.

Specified by:
start in interface ch.qos.logback.core.spi.LifeCycle
Overrides:
start in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>

append

protected void append(ch.qos.logback.classic.spi.ILoggingEvent event)
Writes an event to Eclipse's Error Log

Specified by:
append in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
Parameters:
event - the event to be logged

getEncoder

public ch.qos.logback.classic.encoder.PatternLayoutEncoder getEncoder()
Gets the pattern-layout encoder for this appender's log message

Returns:
the pattern-layout encoder

setEncoder

public void setEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder encoder)
Sets the pattern-layout encoder for this appender's log message

Parameters:
encoder - the pattern-layout encoder

getBundleName

public String getBundleName()
Gets the symbolic name of the Eclipse plugin bundle whose logger is used for logging messages

Returns:
the symbolic name of the Eclipse plugin bundle

setBundleName

public void setBundleName(String bundleName)
Sets the name of the Eclipse plugin bundle whose logger will be used for logging messages. This must match the name from the "Bundle-SymbolicName" property of the bundle's manifest. If start() is called without setting this value, this Eclipse logback extension's bundle name is used as a default.

Parameters:
bundleName - the symbolic name of the Eclipse plugin bundle

getPlatform

protected IPlatform getPlatform()
Gets the Eclipse platform



Copyright © 2012-2013. All Rights Reserved.