Package ch.qos.logback.access.tomcat
Class LogbackValve
- java.lang.Object
-
- org.apache.catalina.util.LifecycleBase
-
- org.apache.catalina.util.LifecycleMBeanBase
-
- org.apache.catalina.valves.ValveBase
-
- ch.qos.logback.access.tomcat.LogbackValve
-
- All Implemented Interfaces:
Context,AppenderAttachable<IAccessEvent>,FilterAttachable<IAccessEvent>,PropertyContainer,MBeanRegistration,org.apache.catalina.Contained,org.apache.catalina.JmxEnabled,org.apache.catalina.Lifecycle,org.apache.catalina.Valve
public class LogbackValve extends org.apache.catalina.valves.ValveBase implements org.apache.catalina.Lifecycle, Context, AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent>
This class is an implementation of tomcat's Valve interface, by extending ValveBase.For more information on using LogbackValve please refer to the online documentation on logback-acces and tomcat.
- Author:
- Ceki Gülcü, Sébastien Pennec
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_CONFIG_FILEstatic StringDEFAULT_FILENAME-
Fields inherited from class org.apache.catalina.valves.ValveBase
asyncSupported, container, containerLog, next
-
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
-
-
Constructor Summary
Constructors Constructor Description LogbackValve()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAppender(Appender<IAccessEvent> newAppender)Add an appender.voidaddError(String msg, Throwable t)voidaddFilter(Filter<IAccessEvent> newFilter)Add a filter.voidaddInfo(String msg)voidaddLifecycleListener(org.apache.catalina.LifecycleListener arg0)voidaddScheduledFuture(ScheduledFuture<?> scheduledFuture)voidaddStatus(Status status)voidaddWarn(String msg)voidclearAllFilters()voiddetachAndStopAllAppenders()Detach and processPriorToRemoval all previously added appenders.booleandetachAppender(Appender<IAccessEvent> appender)Detach the appender passed as parameter from the list of appenders.booleandetachAppender(String name)Detach the appender with the name passed as parameter from the list of appenders.org.apache.catalina.LifecycleListener[]findLifecycleListeners()Appender<IAccessEvent>getAppender(String name)Get an appender by name.longgetBirthTime()The time at which this context was created, expressed in millisecond elapsed since the epoch (1.1.1970).ObjectgetConfigurationLock()Object used for synchronization purposes.List<Filter<IAccessEvent>>getCopyOfAttachedFiltersList()Get a copy of all the filters contained within this FilterAttachable object.Map<String,String>getCopyOfPropertyMap()Get a copy of the property mapExecutorServicegetExecutorService()Every context has an ExecutorService which be invoked to execute certain tasks in a separate thread.StringgetFilename()FilterReplygetFilterChainDecision(IAccessEvent event)Loop through the filters in the chain.StringgetInfo()StringgetName()Contexts are named objects.ObjectgetObject(String key)A Context can act as a store for various objects used by LOGBack components.StringgetProperty(String key)Get the property of this context.Map<String,String>getPropertyMap()ScheduledExecutorServicegetScheduledExecutorService()Returns the ScheduledExecutorService for this context.StatusManagergetStatusManager()Return the StatusManager instance in use.voidinvoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response)booleanisAttached(Appender<IAccessEvent> appender)Returnstrueif the specified appender is in list of attached attached,falseotherwise.booleanisQuiet()booleanisStarted()Iterator<Appender<IAccessEvent>>iteratorForAppenders()Get an iterator for appenders contained in the parent object.voidputObject(String key, Object value)Store an object under 'key'.voidputProperty(String key, String val)Set a property of this context.voidregister(LifeCycle component)Register a component that participates in the context's life cycle.voidremoveLifecycleListener(org.apache.catalina.LifecycleListener arg0)voidsetFilename(String filename)voidsetName(String name)The name of the context can be set only once.voidsetQuiet(boolean quiet)voidstartInternal()protected voidstopInternal()StringtoString()-
Methods inherited from class org.apache.catalina.valves.ValveBase
backgroundProcess, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext
-
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister
-
Methods inherited from class org.apache.catalina.util.LifecycleBase
destroy, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, setState, setState, setThrowOnFailure, start, stop
-
-
-
-
Field Detail
-
DEFAULT_FILENAME
public static final String DEFAULT_FILENAME
- See Also:
- Constant Field Values
-
DEFAULT_CONFIG_FILE
public static final String DEFAULT_CONFIG_FILE
-
-
Method Detail
-
isStarted
public boolean isStarted()
-
startInternal
public void startInternal() throws org.apache.catalina.LifecycleException- Overrides:
startInternalin classorg.apache.catalina.valves.ValveBase- Throws:
org.apache.catalina.LifecycleException
-
addStatus
public void addStatus(Status status)
-
addInfo
public void addInfo(String msg)
-
addWarn
public void addWarn(String msg)
-
getFilename
public String getFilename()
-
setFilename
public void setFilename(String filename)
-
isQuiet
public boolean isQuiet()
-
setQuiet
public void setQuiet(boolean quiet)
-
invoke
public void invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response) throws IOException, javax.servlet.ServletException- Specified by:
invokein interfaceorg.apache.catalina.Valve- Throws:
IOExceptionjavax.servlet.ServletException
-
stopInternal
protected void stopInternal() throws org.apache.catalina.LifecycleException- Overrides:
stopInternalin classorg.apache.catalina.valves.ValveBase- Throws:
org.apache.catalina.LifecycleException
-
addAppender
public void addAppender(Appender<IAccessEvent> newAppender)
Description copied from interface:AppenderAttachableAdd an appender.- Specified by:
addAppenderin interfaceAppenderAttachable<IAccessEvent>
-
iteratorForAppenders
public Iterator<Appender<IAccessEvent>> iteratorForAppenders()
Description copied from interface:AppenderAttachableGet an iterator for appenders contained in the parent object.- Specified by:
iteratorForAppendersin interfaceAppenderAttachable<IAccessEvent>
-
getAppender
public Appender<IAccessEvent> getAppender(String name)
Description copied from interface:AppenderAttachableGet an appender by name.- Specified by:
getAppenderin interfaceAppenderAttachable<IAccessEvent>
-
isAttached
public boolean isAttached(Appender<IAccessEvent> appender)
Description copied from interface:AppenderAttachableReturnstrueif the specified appender is in list of attached attached,falseotherwise.- Specified by:
isAttachedin interfaceAppenderAttachable<IAccessEvent>
-
detachAndStopAllAppenders
public void detachAndStopAllAppenders()
Description copied from interface:AppenderAttachableDetach and processPriorToRemoval all previously added appenders.- Specified by:
detachAndStopAllAppendersin interfaceAppenderAttachable<IAccessEvent>
-
detachAppender
public boolean detachAppender(Appender<IAccessEvent> appender)
Description copied from interface:AppenderAttachableDetach the appender passed as parameter from the list of appenders.- Specified by:
detachAppenderin interfaceAppenderAttachable<IAccessEvent>
-
detachAppender
public boolean detachAppender(String name)
Description copied from interface:AppenderAttachableDetach the appender with the name passed as parameter from the list of appenders.- Specified by:
detachAppenderin interfaceAppenderAttachable<IAccessEvent>
-
getInfo
public String getInfo()
-
getStatusManager
public StatusManager getStatusManager()
Description copied from interface:ContextReturn the StatusManager instance in use.- Specified by:
getStatusManagerin interfaceContext- Returns:
- the
StatusManagerinstance in use.
-
putProperty
public void putProperty(String key, String val)
Description copied from interface:ContextSet a property of this context.- Specified by:
putPropertyin interfaceContext
-
getProperty
public String getProperty(String key)
Description copied from interface:ContextGet the property of this context.- Specified by:
getPropertyin interfaceContext- Specified by:
getPropertyin interfacePropertyContainer
-
getCopyOfPropertyMap
public Map<String,String> getCopyOfPropertyMap()
Description copied from interface:ContextGet a copy of the property map- Specified by:
getCopyOfPropertyMapin interfaceContext- Specified by:
getCopyOfPropertyMapin interfacePropertyContainer
-
getObject
public Object getObject(String key)
Description copied from interface:ContextA Context can act as a store for various objects used by LOGBack components.
-
putObject
public void putObject(String key, Object value)
Description copied from interface:ContextStore an object under 'key'. If no object can be found, null is returned.
-
addFilter
public void addFilter(Filter<IAccessEvent> newFilter)
Description copied from interface:FilterAttachableAdd a filter.- Specified by:
addFilterin interfaceFilterAttachable<IAccessEvent>
-
clearAllFilters
public void clearAllFilters()
- Specified by:
clearAllFiltersin interfaceFilterAttachable<IAccessEvent>
-
getCopyOfAttachedFiltersList
public List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList()
Description copied from interface:FilterAttachableGet a copy of all the filters contained within this FilterAttachable object.- Specified by:
getCopyOfAttachedFiltersListin interfaceFilterAttachable<IAccessEvent>- Returns:
- all attached filters as a list
-
getFilterChainDecision
public FilterReply getFilterChainDecision(IAccessEvent event)
Description copied from interface:FilterAttachableLoop through the filters in the chain. As soon as a filter decides on ACCEPT or DENY, then that value is returned. If all of the filters return NEUTRAL, then NEUTRAL is returned.- Specified by:
getFilterChainDecisionin interfaceFilterAttachable<IAccessEvent>
-
getExecutorService
public ExecutorService getExecutorService()
Description copied from interface:ContextEvery context has an ExecutorService which be invoked to execute certain tasks in a separate thread.- Specified by:
getExecutorServicein interfaceContext- Returns:
- the executor for this context.
-
getName
public String getName()
Description copied from interface:ContextContexts are named objects.
-
setName
public void setName(String name)
Description copied from interface:ContextThe name of the context can be set only once.
-
getBirthTime
public long getBirthTime()
Description copied from interface:ContextThe time at which this context was created, expressed in millisecond elapsed since the epoch (1.1.1970).- Specified by:
getBirthTimein interfaceContext- Returns:
- The time as measured when this class was created.
-
getConfigurationLock
public Object getConfigurationLock()
Description copied from interface:ContextObject used for synchronization purposes. INTENDED FOR INTERNAL USAGE.- Specified by:
getConfigurationLockin interfaceContext
-
register
public void register(LifeCycle component)
Description copied from interface:ContextRegister a component that participates in the context's life cycle.All components registered via this method will be stopped and removed from the context when the context is reset.
-
addLifecycleListener
public void addLifecycleListener(org.apache.catalina.LifecycleListener arg0)
- Specified by:
addLifecycleListenerin interfaceorg.apache.catalina.Lifecycle- Overrides:
addLifecycleListenerin classorg.apache.catalina.util.LifecycleBase
-
findLifecycleListeners
public org.apache.catalina.LifecycleListener[] findLifecycleListeners()
- Specified by:
findLifecycleListenersin interfaceorg.apache.catalina.Lifecycle- Overrides:
findLifecycleListenersin classorg.apache.catalina.util.LifecycleBase
-
removeLifecycleListener
public void removeLifecycleListener(org.apache.catalina.LifecycleListener arg0)
- Specified by:
removeLifecycleListenerin interfaceorg.apache.catalina.Lifecycle- Overrides:
removeLifecycleListenerin classorg.apache.catalina.util.LifecycleBase
-
toString
public String toString()
- Overrides:
toStringin classorg.apache.catalina.valves.ValveBase
-
getScheduledExecutorService
public ScheduledExecutorService getScheduledExecutorService()
Description copied from interface:ContextReturns the ScheduledExecutorService for this context.- Specified by:
getScheduledExecutorServicein interfaceContext- Returns:
-
addScheduledFuture
public void addScheduledFuture(ScheduledFuture<?> scheduledFuture)
- Specified by:
addScheduledFuturein interfaceContext
-
-