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
,javax.management.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 java.lang.String
DEFAULT_CONFIG_FILE
static java.lang.String
DEFAULT_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 void
addAppender(Appender<IAccessEvent> newAppender)
Add an appender.void
addError(java.lang.String msg, java.lang.Throwable t)
void
addFilter(Filter<IAccessEvent> newFilter)
Add a filter.void
addInfo(java.lang.String msg)
void
addLifecycleListener(org.apache.catalina.LifecycleListener arg0)
void
addScheduledFuture(java.util.concurrent.ScheduledFuture<?> scheduledFuture)
void
addStatus(Status status)
void
addWarn(java.lang.String msg)
void
clearAllFilters()
void
detachAndStopAllAppenders()
Detach and processPriorToRemoval all previously added appenders.boolean
detachAppender(Appender<IAccessEvent> appender)
Detach the appender passed as parameter from the list of appenders.boolean
detachAppender(java.lang.String name)
Detach the appender with the name passed as parameter from the list of appenders.org.apache.catalina.LifecycleListener[]
findLifecycleListeners()
Appender<IAccessEvent>
getAppender(java.lang.String name)
Get an appender by name.long
getBirthTime()
The time at which this context was created, expressed in millisecond elapsed since the epoch (1.1.1970).java.lang.Object
getConfigurationLock()
Object used for synchronization purposes.java.util.List<Filter<IAccessEvent>>
getCopyOfAttachedFiltersList()
Get a copy of all the filters contained within this FilterAttachable object.java.util.Map<java.lang.String,java.lang.String>
getCopyOfPropertyMap()
Get a copy of the property mapjava.util.concurrent.ExecutorService
getExecutorService()
Every context has an ExecutorService which be invoked to execute certain tasks in a separate thread.java.lang.String
getFilename()
FilterReply
getFilterChainDecision(IAccessEvent event)
Loop through the filters in the chain.java.lang.String
getInfo()
java.lang.String
getName()
Contexts are named objects.java.lang.Object
getObject(java.lang.String key)
A Context can act as a store for various objects used by LOGBack components.java.lang.String
getProperty(java.lang.String key)
Get the property of this context.java.util.Map<java.lang.String,java.lang.String>
getPropertyMap()
java.util.concurrent.ScheduledExecutorService
getScheduledExecutorService()
Returns the ScheduledExecutorService for this context.StatusManager
getStatusManager()
Return the StatusManager instance in use.void
invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response)
boolean
isAttached(Appender<IAccessEvent> appender)
Returnstrue
if the specified appender is in list of attached attached,false
otherwise.boolean
isQuiet()
boolean
isStarted()
java.util.Iterator<Appender<IAccessEvent>>
iteratorForAppenders()
Get an iterator for appenders contained in the parent object.void
putObject(java.lang.String key, java.lang.Object value)
Store an object under 'key'.void
putProperty(java.lang.String key, java.lang.String val)
Set a property of this context.void
register(LifeCycle component)
Register a component that participates in the context's life cycle.void
removeLifecycleListener(org.apache.catalina.LifecycleListener arg0)
void
setFilename(java.lang.String filename)
void
setName(java.lang.String name)
The name of the context can be set only once.void
setQuiet(boolean quiet)
void
startInternal()
protected void
stopInternal()
java.lang.String
toString()
-
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 java.lang.String DEFAULT_FILENAME
- See Also:
- Constant Field Values
-
DEFAULT_CONFIG_FILE
public static final java.lang.String DEFAULT_CONFIG_FILE
-
-
Method Detail
-
isStarted
public boolean isStarted()
-
startInternal
public void startInternal() throws org.apache.catalina.LifecycleException
- Overrides:
startInternal
in classorg.apache.catalina.valves.ValveBase
- Throws:
org.apache.catalina.LifecycleException
-
addStatus
public void addStatus(Status status)
-
addInfo
public void addInfo(java.lang.String msg)
-
addWarn
public void addWarn(java.lang.String msg)
-
addError
public void addError(java.lang.String msg, java.lang.Throwable t)
-
getFilename
public java.lang.String getFilename()
-
setFilename
public void setFilename(java.lang.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 java.io.IOException, javax.servlet.ServletException
- Specified by:
invoke
in interfaceorg.apache.catalina.Valve
- Throws:
java.io.IOException
javax.servlet.ServletException
-
stopInternal
protected void stopInternal() throws org.apache.catalina.LifecycleException
- Overrides:
stopInternal
in classorg.apache.catalina.valves.ValveBase
- Throws:
org.apache.catalina.LifecycleException
-
addAppender
public void addAppender(Appender<IAccessEvent> newAppender)
Description copied from interface:AppenderAttachable
Add an appender.- Specified by:
addAppender
in interfaceAppenderAttachable<IAccessEvent>
-
iteratorForAppenders
public java.util.Iterator<Appender<IAccessEvent>> iteratorForAppenders()
Description copied from interface:AppenderAttachable
Get an iterator for appenders contained in the parent object.- Specified by:
iteratorForAppenders
in interfaceAppenderAttachable<IAccessEvent>
-
getAppender
public Appender<IAccessEvent> getAppender(java.lang.String name)
Description copied from interface:AppenderAttachable
Get an appender by name.- Specified by:
getAppender
in interfaceAppenderAttachable<IAccessEvent>
-
isAttached
public boolean isAttached(Appender<IAccessEvent> appender)
Description copied from interface:AppenderAttachable
Returnstrue
if the specified appender is in list of attached attached,false
otherwise.- Specified by:
isAttached
in interfaceAppenderAttachable<IAccessEvent>
-
detachAndStopAllAppenders
public void detachAndStopAllAppenders()
Description copied from interface:AppenderAttachable
Detach and processPriorToRemoval all previously added appenders.- Specified by:
detachAndStopAllAppenders
in interfaceAppenderAttachable<IAccessEvent>
-
detachAppender
public boolean detachAppender(Appender<IAccessEvent> appender)
Description copied from interface:AppenderAttachable
Detach the appender passed as parameter from the list of appenders.- Specified by:
detachAppender
in interfaceAppenderAttachable<IAccessEvent>
-
detachAppender
public boolean detachAppender(java.lang.String name)
Description copied from interface:AppenderAttachable
Detach the appender with the name passed as parameter from the list of appenders.- Specified by:
detachAppender
in interfaceAppenderAttachable<IAccessEvent>
-
getInfo
public java.lang.String getInfo()
-
getStatusManager
public StatusManager getStatusManager()
Description copied from interface:Context
Return the StatusManager instance in use.- Specified by:
getStatusManager
in interfaceContext
- Returns:
- the
StatusManager
instance in use.
-
getPropertyMap
public java.util.Map<java.lang.String,java.lang.String> getPropertyMap()
-
putProperty
public void putProperty(java.lang.String key, java.lang.String val)
Description copied from interface:Context
Set a property of this context.- Specified by:
putProperty
in interfaceContext
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Description copied from interface:Context
Get the property of this context.- Specified by:
getProperty
in interfaceContext
- Specified by:
getProperty
in interfacePropertyContainer
-
getCopyOfPropertyMap
public java.util.Map<java.lang.String,java.lang.String> getCopyOfPropertyMap()
Description copied from interface:Context
Get a copy of the property map- Specified by:
getCopyOfPropertyMap
in interfaceContext
- Specified by:
getCopyOfPropertyMap
in interfacePropertyContainer
-
getObject
public java.lang.Object getObject(java.lang.String key)
Description copied from interface:Context
A Context can act as a store for various objects used by LOGBack components.
-
putObject
public void putObject(java.lang.String key, java.lang.Object value)
Description copied from interface:Context
Store an object under 'key'. If no object can be found, null is returned.
-
addFilter
public void addFilter(Filter<IAccessEvent> newFilter)
Description copied from interface:FilterAttachable
Add a filter.- Specified by:
addFilter
in interfaceFilterAttachable<IAccessEvent>
-
clearAllFilters
public void clearAllFilters()
- Specified by:
clearAllFilters
in interfaceFilterAttachable<IAccessEvent>
-
getCopyOfAttachedFiltersList
public java.util.List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList()
Description copied from interface:FilterAttachable
Get a copy of all the filters contained within this FilterAttachable object.- Specified by:
getCopyOfAttachedFiltersList
in interfaceFilterAttachable<IAccessEvent>
- Returns:
- all attached filters as a list
-
getFilterChainDecision
public FilterReply getFilterChainDecision(IAccessEvent event)
Description copied from interface:FilterAttachable
Loop 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:
getFilterChainDecision
in interfaceFilterAttachable<IAccessEvent>
-
getExecutorService
public java.util.concurrent.ExecutorService getExecutorService()
Description copied from interface:Context
Every context has an ExecutorService which be invoked to execute certain tasks in a separate thread.- Specified by:
getExecutorService
in interfaceContext
- Returns:
- the executor for this context.
-
getName
public java.lang.String getName()
Description copied from interface:Context
Contexts are named objects.
-
setName
public void setName(java.lang.String name)
Description copied from interface:Context
The name of the context can be set only once.
-
getBirthTime
public long getBirthTime()
Description copied from interface:Context
The time at which this context was created, expressed in millisecond elapsed since the epoch (1.1.1970).- Specified by:
getBirthTime
in interfaceContext
- Returns:
- The time as measured when this class was created.
-
getConfigurationLock
public java.lang.Object getConfigurationLock()
Description copied from interface:Context
Object used for synchronization purposes. INTENDED FOR INTERNAL USAGE.- Specified by:
getConfigurationLock
in interfaceContext
-
register
public void register(LifeCycle component)
Description copied from interface:Context
Register 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:
addLifecycleListener
in interfaceorg.apache.catalina.Lifecycle
- Overrides:
addLifecycleListener
in classorg.apache.catalina.util.LifecycleBase
-
findLifecycleListeners
public org.apache.catalina.LifecycleListener[] findLifecycleListeners()
- Specified by:
findLifecycleListeners
in interfaceorg.apache.catalina.Lifecycle
- Overrides:
findLifecycleListeners
in classorg.apache.catalina.util.LifecycleBase
-
removeLifecycleListener
public void removeLifecycleListener(org.apache.catalina.LifecycleListener arg0)
- Specified by:
removeLifecycleListener
in interfaceorg.apache.catalina.Lifecycle
- Overrides:
removeLifecycleListener
in classorg.apache.catalina.util.LifecycleBase
-
toString
public java.lang.String toString()
- Overrides:
toString
in classorg.apache.catalina.valves.ValveBase
-
getScheduledExecutorService
public java.util.concurrent.ScheduledExecutorService getScheduledExecutorService()
Description copied from interface:Context
Returns the ScheduledExecutorService for this context.- Specified by:
getScheduledExecutorService
in interfaceContext
- Returns:
-
addScheduledFuture
public void addScheduledFuture(java.util.concurrent.ScheduledFuture<?> scheduledFuture)
- Specified by:
addScheduledFuture
in interfaceContext
-
-