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, 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.
Send an e-mail when a specific logging event occurs, typically on errors or fatal errors. For more information about this appender, please refer to the online manual at

Ceki Gülcü
Sébastien Pennec
 public class SMTPAppender extends SMTPAppenderBase<ILoggingEvent> {
   // value "%logger{20} - %m" is referenced in the docs!
   static final String DEFAULT_SUBJECT_PATTERN = "%logger{20} - %m";
   private int bufferSize = 512;
   private boolean includeCallerData = false;

The default constructor will instantiate the appender with a EventEvaluator that will trigger on events with level ERROR or higher.
   public SMTPAppender() {
   public void start() {    
     if ( == null) {
       OnErrorEvaluator onError = new OnErrorEvaluator();
       this. = onError;      

Use the parameter as the EventEvaluator for this SMTPAppender.
   public SMTPAppender(EventEvaluator<ILoggingEventeventEvaluator) {
     this. = eventEvaluator;

Perform SMTPAppender specific appending actions, mainly adding the event to a cyclic buffer.
   protected void subAppend(CyclicBuffer<ILoggingEventcbILoggingEvent event) {
     if() {
   protected void fillBuffer(CyclicBuffer<ILoggingEventcbStringBuffer sbuf) {
     int len = cb.length();
     for (int i = 0; i < leni++) {
       ILoggingEvent event = cb.get();
   protected boolean isEventMarkedForBufferRemoval(ILoggingEvent eventObject) {
     Marker marker = eventObject.getMarker();
     if(marker == null)
       return false;
  protected Layout<ILoggingEventmakeSubjectLayout(String subjectStr) {
    if(subjectStr == null) {
      subjectStr = ;
    PatternLayout pl = new PatternLayout();
    // we don't want a ThrowableInformationConverter appended
    // to the end of the converter chain
    // This fixes issue LBCLASSIC-67
    return pl;
  protected PatternLayout makeNewToPatternLayout(String toPattern) {
    PatternLayout pl = new PatternLayout();
    return pl;
  public boolean isIncludeCallerData() {
    return ;
  public void setIncludeCallerData(boolean includeCallerData) {
    this. = includeCallerData;
New to GrepCode? Check out our FAQ X