com.sun.enterprise.web
Class PEAccessLogValve

java.lang.Object
  extended by org.apache.catalina.valves.ValveBase
      extended by com.sun.enterprise.web.PEAccessLogValve
All Implemented Interfaces:
java.lang.Runnable, javax.management.MBeanRegistration, Contained, Lifecycle, Valve, GlassFishValve

public final class PEAccessLogValve
extends ValveBase
implements Lifecycle, java.lang.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 mod_log_config module. As an additional feature, automatic rollover of log files at a specified interval is also supported.

This class uses a direct 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, mserver, next, oname, sm, started
 
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
 
Fields inherited from interface org.glassfish.web.valve.GlassFishValve
END_PIPELINE, INVOKE_NEXT
 
Constructor Summary
PEAccessLogValve()
           
 
Method Summary
 void addLifecycleListener(LifecycleListener listener)
          Add a lifecycle event listener to this component.
 java.util.List<LifecycleListener> findLifecycleListeners()
          Gets the (possibly empty) list of lifecycle listeners associated with this PEAccessLogValve.
 int geRotationInterval()
          Return rotation interval
 int getBufferSize()
          Return the direct ByteBuffer size
 java.lang.String getCondition()
          Return whether the attribute name to look for when performing conditional loggging.
 java.lang.String getDirectory()
          Return the directory in which we create log files.
 java.lang.String getFileDateFormat()
          Return the date format date based log rotation.
 java.lang.String getInfo()
          Return descriptive information about this implementation.
 java.lang.String getPrefix()
          Return the log file prefix.
 java.lang.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 the pattern property.
 boolean isResolveHosts()
          Get the value of the resolve hosts flag.
 boolean isRotatable()
          Should we rotate the logs
 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)
           
 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 direct ByteBuffer size
 void setCondition(java.lang.String condition)
          Set the ServletRequest.attribute to look for to perform conditional logging.
 void setDirectory(java.lang.String directory)
          Set the directory in which we create log files.
 void setFileDateFormat(java.lang.String fileDateFormat)
          Set the date format date based log rotation.
 void setPattern(java.lang.String p)
          Set the format pattern, first translating any recognized alias.
 void setPrefix(java.lang.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 logs
 void setRotationInterval(int t)
          Set rotation interval
 void setSuffix(java.lang.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, getContainerName, getController, getDebug, getDomain, getNext, getObjectName, getParentName, invoke, isStarted, postDeregister, postRegister, preDeregister, preRegister, setContainer, setController, setDebug, setNext, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PEAccessLogValve

public PEAccessLogValve()
Method Detail

getWriterInterval

public int getWriterInterval()
Return writerThread interval (seconds)


setWriterInterval

public void setWriterInterval(int t)
Set writerthread interval (seconds)


geRotationInterval

public int geRotationInterval()
Return rotation interval


setRotationInterval

public void setRotationInterval(int t)
Set rotation interval


setBufferSize

public void setBufferSize(int size)
Set the direct ByteBuffer size


getBufferSize

public int getBufferSize()
Return the direct ByteBuffer 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 java.lang.String getDirectory()
Return the directory in which we create log files.


setDirectory

public void setDirectory(java.lang.String directory)
Set the directory in which we create log files.

Parameters:
directory - The new log file directory

getInfo

public java.lang.String getInfo()
Return descriptive information about this implementation.

Specified by:
getInfo in interface Valve
Specified by:
getInfo in interface GlassFishValve
Overrides:
getInfo in class ValveBase

setPattern

public void setPattern(java.lang.String p)
Set the format pattern, first translating any recognized alias.

Parameters:
p - The new pattern

getPrefix

public java.lang.String getPrefix()
Return the log file prefix.


setPrefix

public void setPrefix(java.lang.String p)
Set the log file prefix.

Parameters:
p - prefix The new log file prefix

isRotatable

public boolean isRotatable()
Should we rotate the logs


setRotatable

public void setRotatable(boolean rotatable)
Set the value is we should we rotate the logs

Parameters:
rotatable - true is we should rotate.

getSuffix

public java.lang.String getSuffix()
Return the log file suffix.


setSuffix

public void setSuffix(java.lang.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 java.lang.String getCondition()
Return whether the attribute name to look for when performing conditional loggging. If null, every request is logged.


setCondition

public void setCondition(java.lang.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 java.lang.String getFileDateFormat()
Return the date format date based log rotation.


setFileDateFormat

public void setFileDateFormat(java.lang.String fileDateFormat)
Set the date format date based log rotation.


invoke

public int invoke(Request request,
                  Response response)
Log a message summarizing the specified request and response, according to the format specified by the pattern property.

Specified by:
invoke in interface GlassFishValve
Specified by:
invoke in class ValveBase
Parameters:
request - Request being processed
response - Response being processed

postInvoke

public void postInvoke(Request request,
                       Response response)
                throws java.io.IOException
Specified by:
postInvoke in interface GlassFishValve
Overrides:
postInvoke in class ValveBase
Throws:
java.io.IOException

log

public void log()
         throws java.io.IOException
Log the specified message to the log file, switching files if the date has changed since the previous log call.

Throws:
java.io.IOException

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.

Specified by:
addLifecycleListener in interface Lifecycle
Overrides:
addLifecycleListener in class ValveBase
Parameters:
listener - The listener to add

findLifecycleListeners

public java.util.List<LifecycleListener> findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this PEAccessLogValve.

Specified by:
findLifecycleListeners in interface Lifecycle
Overrides:
findLifecycleListeners in class ValveBase

removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.

Specified by:
removeLifecycleListener in interface Lifecycle
Overrides:
removeLifecycleListener in class ValveBase
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 after configure(), and before any of the public methods of the component are utilized.

Specified by:
start in interface Lifecycle
Overrides:
start in class ValveBase
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 interface Lifecycle
Overrides:
stop in class ValveBase
Throws:
LifecycleException - if this component detects a fatal error that needs to be reported

run

public void run()
The background writerThread that checks for write the log.

Specified by:
run in interface java.lang.Runnable


Copyright © 2012 GlassFish Community. All Rights Reserved.