Package ch.qos.logback.access.jetty
Class RequestLogImpl
java.lang.Object
ch.qos.logback.core.ContextBase
ch.qos.logback.access.jetty.RequestLogImpl
- All Implemented Interfaces:
Context,AppenderAttachable<IAccessEvent>,FilterAttachable<IAccessEvent>,LifeCycle,PropertyContainer,org.eclipse.jetty.server.RequestLog,org.eclipse.jetty.util.component.LifeCycle
public class RequestLogImpl
extends ContextBase
implements org.eclipse.jetty.util.component.LifeCycle, org.eclipse.jetty.server.RequestLog, AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent>
This class is logback's implementation of jetty's RequestLog interface.
It can be seen as logback classic's LoggerContext. Appenders can be attached directly to RequestLogImpl and RequestLogImpl uses the same StatusManager as LoggerContext does. It also provides containers for properties.
To configure jetty in order to use RequestLogImpl, the following lines must be added to the jetty configuration file, namely etc/jetty.xml:
<Ref id="requestLog">
<Set name="requestLog">
<New id="requestLogImpl" class="ch.qos.logback.access.jetty.RequestLogImpl"></New>
</Set>
</Ref>
By default, RequestLogImpl looks for a logback configuration file called
logback-access.xml, in the same folder where jetty.xml is located, that is
etc/logback-access.xml. The logback-access.xml file is slightly
different from the usual logback classic configuration file. Most of it is
the same: Appenders and Layouts are declared the exact same way. However,
loggers elements are not allowed.
It is possible to put the logback configuration file anywhere, as long as it's path is specified. Here is another example, with a path to the logback-access.xml file.
<Ref id="requestLog">
<Set name="requestLog">
<New id="requestLogImpl" class="ch.qos.logback.access.jetty.RequestLogImpl"></New>
<Set name="fileName">path/to/logback.xml</Set>
</Set>
</Ref>
Here is a sample logback-access.xml file that can be used right away:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.access.PatternLayout">
<param name="Pattern" value="%date %server %remoteIP %clientHost %user %requestURL" />
</layout>
</appender>
<appender-ref ref="STDOUT" />
</configuration>
Another configuration file, using SMTPAppender, could be:
<configuration>
<appender name="SMTP" class="ch.qos.logback.access.net.SMTPAppender">
<layout class="ch.qos.logback.access.PatternLayout">
<param name="pattern" value="%remoteIP [%date] %requestURL %statusCode %bytesSent" />
</layout>
<param name="From" value="[email protected]" />
<param name="SMTPHost" value="mail.domain.org" />
<param name="Subject" value="Last Event: %statusCode %requestURL" />
<param name="To" value="[email protected]" />
</appender>
<appender-ref ref="SMTP" />
</configuration>
- Author:
- Ceki Gülcü, Sébastien Pennec
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.server.RequestLog
org.eclipse.jetty.server.RequestLog.Collection, org.eclipse.jetty.server.RequestLog.Writer -
Field Summary
FieldsFields inherited from class ch.qos.logback.core.ContextBase
scheduledFutures -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAppender(Appender<IAccessEvent> newAppender) booleanaddEventListener(EventListener listener) voidaddFilter(Filter<IAccessEvent> newFilter) voidprotected voidvoidbooleandetachAppender(Appender<IAccessEvent> appender) booleandetachAppender(String name) getAppender(String name) protected URLbooleanisAttached(Appender<IAccessEvent> appender) booleanisFailed()booleanisQuiet()booleanbooleanbooleanbooleanbooleanvoidlog(org.eclipse.jetty.server.Request jettyRequest, org.eclipse.jetty.server.Response jettyResponse) booleanremoveEventListener(EventListener listener) voidsetFileName(String fileName) voidsetQuiet(boolean quiet) voidsetResource(String resource) voidstart()voidstop()Methods inherited from class ch.qos.logback.core.ContextBase
addScheduledFuture, getBirthTime, getConfigurationLock, getCopyOfPropertyMap, getCopyOfScheduledFutures, getExecutorService, getName, getObject, getProperty, getScheduledExecutorService, getScheduledFutures, getSequenceNumberGenerator, getStatusManager, initCollisionMaps, putObject, putProperty, register, removeObject, reset, setName, setSequenceNumberGenerator, setStatusManager, toString
-
Field Details
-
DEFAULT_CONFIG_FILE
-
-
Constructor Details
-
RequestLogImpl
public RequestLogImpl()
-
-
Method Details
-
log
public void log(org.eclipse.jetty.server.Request jettyRequest, org.eclipse.jetty.server.Response jettyResponse) - Specified by:
login interfaceorg.eclipse.jetty.server.RequestLog
-
start
public void start()- Specified by:
startin interfaceLifeCycle- Specified by:
startin interfaceorg.eclipse.jetty.util.component.LifeCycle- Overrides:
startin classContextBase
-
configure
protected void configure() -
getConfigurationFileURL
-
stop
public void stop()- Specified by:
stopin interfaceLifeCycle- Specified by:
stopin interfaceorg.eclipse.jetty.util.component.LifeCycle- Overrides:
stopin classContextBase
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceorg.eclipse.jetty.util.component.LifeCycle
-
setFileName
-
setResource
-
isStarted
public boolean isStarted()- Specified by:
isStartedin interfaceLifeCycle- Specified by:
isStartedin interfaceorg.eclipse.jetty.util.component.LifeCycle- Overrides:
isStartedin classContextBase
-
isStarting
public boolean isStarting()- Specified by:
isStartingin interfaceorg.eclipse.jetty.util.component.LifeCycle
-
isStopping
public boolean isStopping()- Specified by:
isStoppingin interfaceorg.eclipse.jetty.util.component.LifeCycle
-
isStopped
public boolean isStopped()- Specified by:
isStoppedin interfaceorg.eclipse.jetty.util.component.LifeCycle
-
isFailed
public boolean isFailed()- Specified by:
isFailedin interfaceorg.eclipse.jetty.util.component.LifeCycle
-
isQuiet
public boolean isQuiet() -
setQuiet
public void setQuiet(boolean quiet) -
addAppender
- Specified by:
addAppenderin interfaceAppenderAttachable<IAccessEvent>
-
iteratorForAppenders
- Specified by:
iteratorForAppendersin interfaceAppenderAttachable<IAccessEvent>
-
getAppender
- Specified by:
getAppenderin interfaceAppenderAttachable<IAccessEvent>
-
isAttached
- Specified by:
isAttachedin interfaceAppenderAttachable<IAccessEvent>
-
detachAndStopAllAppenders
public void detachAndStopAllAppenders()- Specified by:
detachAndStopAllAppendersin interfaceAppenderAttachable<IAccessEvent>
-
detachAppender
- Specified by:
detachAppenderin interfaceAppenderAttachable<IAccessEvent>
-
detachAppender
- Specified by:
detachAppenderin interfaceAppenderAttachable<IAccessEvent>
-
addFilter
- Specified by:
addFilterin interfaceFilterAttachable<IAccessEvent>
-
clearAllFilters
public void clearAllFilters()- Specified by:
clearAllFiltersin interfaceFilterAttachable<IAccessEvent>
-
getCopyOfAttachedFiltersList
- Specified by:
getCopyOfAttachedFiltersListin interfaceFilterAttachable<IAccessEvent>
-
getFilterChainDecision
- Specified by:
getFilterChainDecisionin interfaceFilterAttachable<IAccessEvent>
-
addEventListener
- Specified by:
addEventListenerin interfaceorg.eclipse.jetty.util.component.LifeCycle
-
removeEventListener
- Specified by:
removeEventListenerin interfaceorg.eclipse.jetty.util.component.LifeCycle
-