public class RequestLogImpl extends ContextBase implements org.eclipse.jetty.server.RequestLog, AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent>
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 than 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>
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CONFIG_FILE |
| Constructor and Description |
|---|
RequestLogImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAppender(Appender<IAccessEvent> newAppender) |
void |
addFilter(Filter<IAccessEvent> newFilter) |
void |
addLifeCycleListener(org.eclipse.jetty.util.component.LifeCycle.Listener listener) |
void |
clearAllFilters() |
void |
detachAndStopAllAppenders() |
boolean |
detachAppender(Appender<IAccessEvent> appender) |
boolean |
detachAppender(String name) |
Appender<IAccessEvent> |
getAppender(String name) |
List<Filter<IAccessEvent>> |
getCopyOfAttachedFiltersList() |
FilterReply |
getFilterChainDecision(IAccessEvent event) |
boolean |
isAttached(Appender<IAccessEvent> appender) |
boolean |
isFailed() |
boolean |
isQuiet() |
boolean |
isRunning() |
boolean |
isStarted() |
boolean |
isStarting() |
boolean |
isStopped() |
boolean |
isStopping() |
Iterator<Appender<IAccessEvent>> |
iteratorForAppenders() |
void |
log(org.eclipse.jetty.server.Request jettyRequest,
org.eclipse.jetty.server.Response jettyResponse) |
void |
removeLifeCycleListener(org.eclipse.jetty.util.component.LifeCycle.Listener listener) |
void |
setFileName(String fileName) |
void |
setQuiet(boolean quiet) |
void |
setResource(String resource) |
void |
start() |
void |
stop() |
getBirthTime, getConfigurationLock, getCopyOfPropertyMap, getExecutorService, getName, getObject, getProperty, getStatusManager, putObject, putProperty, reset, setName, setStatusManager, toStringpublic static final String DEFAULT_CONFIG_FILE
public void log(org.eclipse.jetty.server.Request jettyRequest,
org.eclipse.jetty.server.Response jettyResponse)
log in interface org.eclipse.jetty.server.RequestLogpublic void start()
start in interface org.eclipse.jetty.util.component.LifeCyclepublic void stop()
stop in interface org.eclipse.jetty.util.component.LifeCyclepublic boolean isRunning()
isRunning in interface org.eclipse.jetty.util.component.LifeCyclepublic void setFileName(String fileName)
public void setResource(String resource)
public boolean isStarted()
isStarted in interface org.eclipse.jetty.util.component.LifeCyclepublic boolean isStarting()
isStarting in interface org.eclipse.jetty.util.component.LifeCyclepublic boolean isStopping()
isStopping in interface org.eclipse.jetty.util.component.LifeCyclepublic boolean isStopped()
isStopped in interface org.eclipse.jetty.util.component.LifeCyclepublic boolean isFailed()
isFailed in interface org.eclipse.jetty.util.component.LifeCyclepublic boolean isQuiet()
public void setQuiet(boolean quiet)
public void addAppender(Appender<IAccessEvent> newAppender)
addAppender in interface AppenderAttachable<IAccessEvent>public Iterator<Appender<IAccessEvent>> iteratorForAppenders()
iteratorForAppenders in interface AppenderAttachable<IAccessEvent>public Appender<IAccessEvent> getAppender(String name)
getAppender in interface AppenderAttachable<IAccessEvent>public boolean isAttached(Appender<IAccessEvent> appender)
isAttached in interface AppenderAttachable<IAccessEvent>public void detachAndStopAllAppenders()
detachAndStopAllAppenders in interface AppenderAttachable<IAccessEvent>public boolean detachAppender(Appender<IAccessEvent> appender)
detachAppender in interface AppenderAttachable<IAccessEvent>public boolean detachAppender(String name)
detachAppender in interface AppenderAttachable<IAccessEvent>public void addFilter(Filter<IAccessEvent> newFilter)
addFilter in interface FilterAttachable<IAccessEvent>public void clearAllFilters()
clearAllFilters in interface FilterAttachable<IAccessEvent>public List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList()
getCopyOfAttachedFiltersList in interface FilterAttachable<IAccessEvent>public FilterReply getFilterChainDecision(IAccessEvent event)
getFilterChainDecision in interface FilterAttachable<IAccessEvent>public void addLifeCycleListener(org.eclipse.jetty.util.component.LifeCycle.Listener listener)
addLifeCycleListener in interface org.eclipse.jetty.util.component.LifeCyclepublic void removeLifeCycleListener(org.eclipse.jetty.util.component.LifeCycle.Listener listener)
removeLifeCycleListener in interface org.eclipse.jetty.util.component.LifeCycleCopyright © 2005-2013 QOS.ch. All Rights Reserved.