Package com.sun.enterprise.web
Class PEAccessLogValve
- java.lang.Object
-
- org.apache.catalina.valves.ValveBase
-
- com.sun.enterprise.web.PEAccessLogValve
-
- All Implemented Interfaces:
Runnable,Contained,Lifecycle,Valve,GlassFishValve
public final class PEAccessLogValve extends ValveBase implements Runnable
Implementation of the Valve interface that generates a web server access log with the detailed line contents matching a configurable pattern. The syntax of the available patterns is similar to that supported by the Apache
This class uses a directmod_log_configmodule. As an additional feature, automatic rollover of log files at a specified interval is also supported.ByteBufferto store and write logs.- Author:
- Jean-Francois Arcand, Charlie J. Hunt
-
-
Field Summary
-
Fields inherited from class org.apache.catalina.valves.ValveBase
container, controller, debug, domain, lifecycle, log, next, oname, rb, started
-
Fields inherited from interface org.glassfish.web.valve.GlassFishValve
END_PIPELINE, INVOKE_NEXT
-
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, INIT_EVENT, START_EVENT, STOP_EVENT
-
-
Constructor Summary
Constructors Constructor Description PEAccessLogValve()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLifecycleListener(LifecycleListener listener)Add a lifecycle event listener to this component.List<LifecycleListener>findLifecycleListeners()Gets the (possibly empty) list of lifecycle listeners associated with this PEAccessLogValve.intgeRotationInterval()Return rotation intervalintgetBufferSize()Return the directByteBuffersizeStringgetCondition()Return whether the attribute name to look for when performing conditional loggging.StringgetDirectory()Return the directory in which we create log files.StringgetFileDateFormat()Return the date format date based log rotation.StringgetInfo()Return descriptive information about this implementation.StringgetPrefix()Return the log file prefix.StringgetSuffix()Return the log file suffix.intgetWriterInterval()Return writerThread interval (seconds)intinvoke(Request request, Response response)Log a message summarizing the specified request and response, according to the format specified by thepatternproperty.booleanisResolveHosts()Get the value of the resolve hosts flag.booleanisRotatable()Should we rotate the logsbooleanisRotationOnDateChange()voidlog()Log the specified message to the log file, switching files if the date has changed since the previous log call.voidpostInvoke(Request request, Response response)A post-request processing implementation that does nothing.voidremoveLifecycleListener(LifecycleListener listener)Remove a lifecycle event listener from this component.voidrun()The background writerThread that checks for write the log.voidsetAddDateStampToFirstAccessLogFile(boolean add)Are we supposed to add datestamp to first access log file we create, or only starting with first rotation?voidsetBufferSize(int size)Set the directByteBuffersizevoidsetCondition(String condition)Set the ServletRequest.attribute to look for to perform conditional logging.voidsetDirectory(String directory)Set the directory in which we create log files.voidsetFileDateFormat(String fileDateFormat)Set the date format date based log rotation.voidsetPattern(String p)Set the format pattern, first translating any recognized alias.voidsetPrefix(String p)Set the log file prefix.voidsetResolveHosts(boolean resolveHosts)Set the resolve hosts flag.voidsetRotatable(boolean rotatable)Set the value is we should we rotate the logsvoidsetRotationInterval(int t)Set rotation intervalvoidsetRotationOnDateChange(boolean rotationOnDateChange)voidsetSuffix(String s)Set the log file suffix.voidsetWriterInterval(int t)Set writerthread interval (seconds)voidstart()Prepare for the beginning of active use of the public methods of this component.voidstop()Gracefully terminate the active use of the public methods of this component.-
Methods inherited from class org.apache.catalina.valves.ValveBase
backgroundProcess, createObjectName, event, getContainer, getController, getDebug, getDomain, getNext, getObjectName, getParentName, invoke, isStarted, setContainer, setController, setDebug, setNext, setObjectName
-
-
-
-
Method Detail
-
getWriterInterval
public int getWriterInterval()
Return writerThread interval (seconds)
-
setWriterInterval
public void setWriterInterval(int t)
Set writerthread interval (seconds)- Parameters:
t-
-
geRotationInterval
public int geRotationInterval()
Return rotation interval- Returns:
-
setRotationInterval
public void setRotationInterval(int t)
Set rotation interval
-
setBufferSize
public void setBufferSize(int size)
Set the directByteBuffersize- Parameters:
size-
-
getBufferSize
public int getBufferSize()
Return the directByteBuffersize
-
setAddDateStampToFirstAccessLogFile
public void setAddDateStampToFirstAccessLogFile(boolean add)
Are we supposed to add datestamp to first access log file we create, or only starting with first rotation?
-
getDirectory
public String getDirectory()
Return the directory in which we create log files.- Returns:
-
setDirectory
public void setDirectory(String directory)
Set the directory in which we create log files.- Parameters:
directory- The new log file directory
-
getInfo
public String getInfo()
Return descriptive information about this implementation.
-
setPattern
public void setPattern(String p)
Set the format pattern, first translating any recognized alias.- Parameters:
p- The new pattern
-
getPrefix
public String getPrefix()
Return the log file prefix.- Returns:
-
setPrefix
public void setPrefix(String p)
Set the log file prefix.- Parameters:
p- prefix The new log file prefix
-
isRotatable
public boolean isRotatable()
Should we rotate the logs- Returns:
-
setRotatable
public void setRotatable(boolean rotatable)
Set the value is we should we rotate the logs- Parameters:
rotatable- true is we should rotate.
-
isRotationOnDateChange
public boolean isRotationOnDateChange()
-
setRotationOnDateChange
public void setRotationOnDateChange(boolean rotationOnDateChange)
-
getSuffix
public String getSuffix()
Return the log file suffix.- Returns:
-
setSuffix
public void setSuffix(String s)
Set the log file suffix.- Parameters:
s- suffix The new log file suffix
-
setResolveHosts
public void setResolveHosts(boolean resolveHosts)
Set the resolve hosts flag.- Parameters:
resolveHosts- The new resolve hosts value
-
isResolveHosts
public boolean isResolveHosts()
Get the value of the resolve hosts flag.
-
getCondition
public String getCondition()
Return whether the attribute name to look for when performing conditional loggging. If null, every request is logged.- Returns:
-
setCondition
public void setCondition(String condition)
Set the ServletRequest.attribute to look for to perform conditional logging. Set to null to log everything.- Parameters:
condition- Set to null to log everything
-
getFileDateFormat
public String getFileDateFormat()
Return the date format date based log rotation.- Returns:
-
setFileDateFormat
public void setFileDateFormat(String fileDateFormat)
Set the date format date based log rotation.- Parameters:
fileDateFormat-
-
invoke
public int invoke(Request request, Response response)
Log a message summarizing the specified request and response, according to the format specified by thepatternproperty.- Specified by:
invokein interfaceGlassFishValve- Specified by:
invokein classValveBase- Parameters:
request- Request being processedresponse- Response being processed- Returns:
-
postInvoke
public void postInvoke(Request request, Response response) throws IOException
Description copied from class:ValveBaseA post-request processing implementation that does nothing. Very few Valves override this behaviour as most Valve logic is used for request processing.- Specified by:
postInvokein interfaceGlassFishValve- Overrides:
postInvokein classValveBase- Parameters:
request- The servlet request to be processedresponse- The servlet response to be created- Throws:
IOException- if an input/output error occurs
-
log
public void log() throws IOExceptionLog the specified message to the log file, switching files if the date has changed since the previous log call.- Throws:
IOException
-
addLifecycleListener
public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.- Specified by:
addLifecycleListenerin interfaceLifecycle- Overrides:
addLifecycleListenerin classValveBase- Parameters:
listener- The listener to add
-
findLifecycleListeners
public List<LifecycleListener> findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this PEAccessLogValve.- Specified by:
findLifecycleListenersin interfaceLifecycle- Overrides:
findLifecycleListenersin classValveBase- Returns:
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.- Specified by:
removeLifecycleListenerin interfaceLifecycle- Overrides:
removeLifecycleListenerin classValveBase- Parameters:
listener- The listener to add
-
start
public void start() throws LifecycleExceptionPrepare for the beginning of active use of the public methods of this component. This method should be called afterconfigure(), and before any of the public methods of the component are utilized.- Specified by:
startin interfaceLifecycle- Overrides:
startin classValveBase- Throws:
LifecycleException- if this component detects a fatal error that prevents this component from being used
-
stop
public void stop() throws LifecycleExceptionGracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.- Specified by:
stopin interfaceLifecycle- Overrides:
stopin classValveBase- Throws:
LifecycleException- if this component detects a fatal error that needs to be reported
-
-