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_config
module. As an additional feature, automatic rollover of log files at a specified interval is also supported.ByteBuffer
to 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 void
addLifecycleListener(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.int
geRotationInterval()
Return rotation intervalint
getBufferSize()
Return the directByteBuffer
sizeString
getCondition()
Return whether the attribute name to look for when performing conditional loggging.String
getDirectory()
Return the directory in which we create log files.String
getFileDateFormat()
Return the date format date based log rotation.String
getInfo()
Return descriptive information about this implementation.String
getPrefix()
Return the log file prefix.String
getSuffix()
Return the log file suffix.int
getWriterInterval()
Return writerThread interval (seconds)int
invoke(Request request, Response response)
Log a message summarizing the specified request and response, according to the format specified by thepattern
property.boolean
isResolveHosts()
Get the value of the resolve hosts flag.boolean
isRotatable()
Should we rotate the logsboolean
isRotationOnDateChange()
void
log()
Log the specified message to the log file, switching files if the date has changed since the previous log call.void
postInvoke(Request request, Response response)
A post-request processing implementation that does nothing.void
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.void
run()
The background writerThread that checks for write the log.void
setAddDateStampToFirstAccessLogFile(boolean add)
Are we supposed to add datestamp to first access log file we create, or only starting with first rotation?void
setBufferSize(int size)
Set the directByteBuffer
sizevoid
setCondition(String condition)
Set the ServletRequest.attribute to look for to perform conditional logging.void
setDirectory(String directory)
Set the directory in which we create log files.void
setFileDateFormat(String fileDateFormat)
Set the date format date based log rotation.void
setPattern(String p)
Set the format pattern, first translating any recognized alias.void
setPrefix(String p)
Set the log file prefix.void
setResolveHosts(boolean resolveHosts)
Set the resolve hosts flag.void
setRotatable(boolean rotatable)
Set the value is we should we rotate the logsvoid
setRotationInterval(int t)
Set rotation intervalvoid
setRotationOnDateChange(boolean rotationOnDateChange)
void
setSuffix(String s)
Set the log file suffix.void
setWriterInterval(int t)
Set writerthread interval (seconds)void
start()
Prepare for the beginning of active use of the public methods of this component.void
stop()
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 directByteBuffer
size- Parameters:
size
-
-
getBufferSize
public int getBufferSize()
Return the directByteBuffer
size
-
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 thepattern
property.- Specified by:
invoke
in interfaceGlassFishValve
- Specified by:
invoke
in classValveBase
- Parameters:
request
- Request being processedresponse
- Response being processed- Returns:
-
postInvoke
public void postInvoke(Request request, Response response) throws IOException
Description copied from class:ValveBase
A post-request processing implementation that does nothing. Very few Valves override this behaviour as most Valve logic is used for request processing.- Specified by:
postInvoke
in interfaceGlassFishValve
- Overrides:
postInvoke
in 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 IOException
Log 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:
addLifecycleListener
in interfaceLifecycle
- Overrides:
addLifecycleListener
in 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:
findLifecycleListeners
in interfaceLifecycle
- Overrides:
findLifecycleListeners
in classValveBase
- Returns:
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.- Specified by:
removeLifecycleListener
in interfaceLifecycle
- Overrides:
removeLifecycleListener
in classValveBase
- Parameters:
listener
- The listener to add
-
start
public void start() throws LifecycleException
Prepare 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:
start
in interfaceLifecycle
- Overrides:
start
in classValveBase
- Throws:
LifecycleException
- if this component detects a fatal error that prevents this component from being used
-
stop
public void stop() throws LifecycleException
Gracefully 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:
stop
in interfaceLifecycle
- Overrides:
stop
in classValveBase
- Throws:
LifecycleException
- if this component detects a fatal error that needs to be reported
-
-