001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.classic; 015 016import ch.qos.logback.classic.spi.ILoggingEvent; 017import ch.qos.logback.core.AsyncAppenderBase; 018 019/** 020 * In order to optimize performance this appender deems events of level TRACE, 021 * DEBUG and INFO as discardable. See the 022 * <a href="http://logback.qos.ch/manual/appenders.html#AsyncAppender">chapter 023 * on appenders</a> in the manual for further information. 024 * 025 * 026 * @author Ceki Gülcü 027 * @since 1.0.4 028 */ 029public class AsyncAppender extends AsyncAppenderBase<ILoggingEvent> { 030 031 boolean includeCallerData = false; 032 033 /** 034 * Events of level TRACE, DEBUG and INFO are deemed to be discardable. 035 * 036 * @param event 037 * @return true if the event is of level TRACE, DEBUG or INFO false otherwise. 038 */ 039 protected boolean isDiscardable(ILoggingEvent event) { 040 Level level = event.getLevel(); 041 return level.toInt() <= Level.INFO_INT; 042 } 043 044 protected void preprocess(ILoggingEvent eventObject) { 045 eventObject.prepareForDeferredProcessing(); 046 if (includeCallerData) 047 eventObject.getCallerData(); 048 } 049 050 public boolean isIncludeCallerData() { 051 return includeCallerData; 052 } 053 054 public void setIncludeCallerData(boolean includeCallerData) { 055 this.includeCallerData = includeCallerData; 056 } 057 058}