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="sender@domaine.org" /> <param name="SMTPHost" value="mail.domain.org" /> <param name="Subject" value="Last Event: %statusCode %requestURL" /> <param name="To" value="server_admin@domain.org" /> </appender> <appender-ref ref="SMTP" /> </configuration>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_CONFIG_FILE |
Constructor and Description |
---|
RequestLogImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addAppender(Appender<IAccessEvent> newAppender)
Add an appender.
|
void |
addFilter(Filter<IAccessEvent> newFilter)
Add a filter.
|
void |
addLifeCycleListener(org.eclipse.jetty.util.component.LifeCycle.Listener listener) |
void |
clearAllFilters() |
void |
detachAndStopAllAppenders()
Detach and stop 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.
|
Appender<IAccessEvent> |
getAppender(java.lang.String name)
Get an appender by name.
|
java.util.List<Filter<IAccessEvent>> |
getCopyOfAttachedFiltersList()
Get a copy of all the filters contained within this FilterAttachable
object.
|
FilterReply |
getFilterChainDecision(IAccessEvent event)
Loop through the filters in the chain.
|
boolean |
isAttached(Appender<IAccessEvent> appender)
Returns
true if the specified appender is in list of
attached attached, false otherwise. |
boolean |
isFailed() |
boolean |
isQuiet() |
boolean |
isRunning() |
boolean |
isStarted() |
boolean |
isStarting() |
boolean |
isStopped() |
boolean |
isStopping() |
java.util.Iterator<Appender<IAccessEvent>> |
iteratorForAppenders()
Get an iterator for appenders contained in the parent object.
|
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(java.lang.String fileName) |
void |
setQuiet(boolean quiet) |
void |
setResource(java.lang.String resource) |
void |
start() |
void |
stop() |
getBirthTime, getConfigurationLock, getCopyOfPropertyMap, getExecutorService, getName, getObject, getProperty, getStatusManager, putObject, putProperty, reset, setName, setStatusManager, toString
public void log(org.eclipse.jetty.server.Request jettyRequest, org.eclipse.jetty.server.Response jettyResponse)
log
in interface org.eclipse.jetty.server.RequestLog
public void start()
start
in interface org.eclipse.jetty.util.component.LifeCycle
public void stop()
stop
in interface org.eclipse.jetty.util.component.LifeCycle
public boolean isRunning()
isRunning
in interface org.eclipse.jetty.util.component.LifeCycle
public void setFileName(java.lang.String fileName)
public void setResource(java.lang.String resource)
public boolean isStarted()
isStarted
in interface org.eclipse.jetty.util.component.LifeCycle
public boolean isStarting()
isStarting
in interface org.eclipse.jetty.util.component.LifeCycle
public boolean isStopping()
isStopping
in interface org.eclipse.jetty.util.component.LifeCycle
public boolean isStopped()
isStopped
in interface org.eclipse.jetty.util.component.LifeCycle
public boolean isFailed()
isFailed
in interface org.eclipse.jetty.util.component.LifeCycle
public boolean isQuiet()
public void setQuiet(boolean quiet)
public void addAppender(Appender<IAccessEvent> newAppender)
AppenderAttachable
addAppender
in interface AppenderAttachable<IAccessEvent>
public java.util.Iterator<Appender<IAccessEvent>> iteratorForAppenders()
AppenderAttachable
iteratorForAppenders
in interface AppenderAttachable<IAccessEvent>
public Appender<IAccessEvent> getAppender(java.lang.String name)
AppenderAttachable
getAppender
in interface AppenderAttachable<IAccessEvent>
public boolean isAttached(Appender<IAccessEvent> appender)
AppenderAttachable
true
if the specified appender is in list of
attached attached, false
otherwise.isAttached
in interface AppenderAttachable<IAccessEvent>
public void detachAndStopAllAppenders()
AppenderAttachable
detachAndStopAllAppenders
in interface AppenderAttachable<IAccessEvent>
public boolean detachAppender(Appender<IAccessEvent> appender)
AppenderAttachable
detachAppender
in interface AppenderAttachable<IAccessEvent>
public boolean detachAppender(java.lang.String name)
AppenderAttachable
detachAppender
in interface AppenderAttachable<IAccessEvent>
public void addFilter(Filter<IAccessEvent> newFilter)
FilterAttachable
addFilter
in interface FilterAttachable<IAccessEvent>
public void clearAllFilters()
clearAllFilters
in interface FilterAttachable<IAccessEvent>
public java.util.List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList()
FilterAttachable
getCopyOfAttachedFiltersList
in interface FilterAttachable<IAccessEvent>
public FilterReply getFilterChainDecision(IAccessEvent event)
FilterAttachable
getFilterChainDecision
in interface FilterAttachable<IAccessEvent>
public void addLifeCycleListener(org.eclipse.jetty.util.component.LifeCycle.Listener listener)
addLifeCycleListener
in interface org.eclipse.jetty.util.component.LifeCycle
public void removeLifeCycleListener(org.eclipse.jetty.util.component.LifeCycle.Listener listener)
removeLifeCycleListener
in interface org.eclipse.jetty.util.component.LifeCycle
Copyright © 1999-2012 QOS.ch. All rights reserved