AbstractAccessLogValve that outputs the access log to a file. The
features of this implementation include:
For UNIX users, another field called checkExists is also available. If set to true, the log file's
existence will be checked before each logging. This way an external log rotator can move the file somewhere and
Tomcat will start with a new file.
For JMX junkies, a public method called rotate has been made available to allow you to tell this
instance to move the existing log file to somewhere else and start writing a new log file.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | buffered
Buffered logging. |
| private boolean | checkExists
Do we check for log file existence? |
| private volatile boolean | |
| protected File | currentLogFile
The current log file we are writing to. |
| private volatile String | dateStamp
The as-of date for the currently open log file, or a zero-length string if there is no open log file. |
| private String | directory
The directory in which log files are created. |
| protected volatile String | encoding
Character set used by the log file. |
| protected String | fileDateFormat
Date format to place in log file name. |
| protected SimpleDateFormat | fileDateFormatter
A date formatter to format a Date using the format given by |
| private static final Log | |
| private int | maxDays
The number of days to retain the access log files before they are removed. |
| protected volatile String | prefix
The prefix that is added to log file filenames. |
| protected boolean | renameOnRotate
Should we defer inclusion of the date stamp in the file name until rotate time? |
| protected boolean | rotatable
Should we rotate our log file? |
| private volatile long | rotationLastChecked
Instant when the log daily rotation was last checked. |
| protected volatile String | suffix
The suffix that is added to log file filenames. |
| protected PrintWriter | writer
The PrintWriter to which we are currently logging, if any. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | backgroundProcess()
Overrides org. Implements org. Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. |
| private synchronized void | close(boolean
Rename file to final name after closing rename)Close the currently open log file (if any) |
| public String | |
| private File | |
| public String | Returns: Character set name, ornull if the default character set is used.Return the character set name that is used to write the log file. |
| public String | |
| private File | Returns: the log file objectinclude the timestamp in the file name. useDateStamp)Create a File object based on the current log file name. |
| public int | |
| public String | |
| public String | |
| public boolean | |
| public boolean | Returns: true if file existence is checked firstCheck for file existence before logging. |
| public boolean | Returns: true if the logs file names are time stamped only when they are rotatedShould we defer inclusion of the date stamp in the file name until rotate time. |
| public boolean | |
| public void | log(CharArrayWriter
Message to be logged message)Implements abstract org. Log the specified message to the log file, switching files if the date has changed since the previous log call. |
| protected synchronized void | |
| private void | |
| public void | |
| public synchronized boolean | |
| public void | |
| public void | setCheckExists(boolean
true meaning to check for file existence. checkExists)Set whether to check for log file existence before logging. |
| public void | setDirectory(String
The new log file directory directory)Set the directory in which we create log files. |
| public void | setEncoding(String
The name of the character set. encoding)Set the character set that is used to write the log file. |
| public void | setFileDateFormat(String
The format for the file timestamp fileDateFormat)Set the date format date based log rotation. |
| public void | |
| public void | |
| public void | setRenameOnRotate(boolean
true if defer inclusion of date stamp renameOnRotate)Set the value if we should defer inclusion of the date stamp in the file name until rotate time |
| public void | setRotatable(boolean
true if the log should be rotated rotatable)Configure whether the access log should be rotated. |
| public void | |
| protected void | startInternal()
Overrides org. Start this component and implement the requirements of
|
| protected void | stopInternal()
Overrides org. Stop this component and implement the requirements of
|
| buffered | back to summary |
|---|---|
| private boolean buffered Buffered logging. | |
| checkExists | back to summary |
|---|---|
| private boolean checkExists Do we check for log file existence? Helpful if an external agent renames the log file so we can automagically recreate it. | |
| checkForOldLogs | back to summary |
|---|---|
| private volatile boolean checkForOldLogs | |
| currentLogFile | back to summary |
|---|---|
| protected File currentLogFile The current log file we are writing to. Helpful when checkExists is true. | |
| dateStamp | back to summary |
|---|---|
| private volatile String dateStamp The as-of date for the currently open log file, or a zero-length string if there is no open log file. | |
| directory | back to summary |
|---|---|
| private String directory The directory in which log files are created. | |
| encoding | back to summary |
|---|---|
| protected volatile String encoding Character set used by the log file. If it is | |
| fileDateFormat | back to summary |
|---|---|
| protected String fileDateFormat Date format to place in log file name. | |
| fileDateFormatter | back to summary |
|---|---|
| protected SimpleDateFormat fileDateFormatter A date formatter to format a Date using the format given by | |
| log | back to summary |
|---|---|
| private static final Log log Hides org. | |
| maxDays | back to summary |
|---|---|
| private int maxDays The number of days to retain the access log files before they are removed. | |
| prefix | back to summary |
|---|---|
| protected volatile String prefix The prefix that is added to log file filenames. | |
| renameOnRotate | back to summary |
|---|---|
| protected boolean renameOnRotate Should we defer inclusion of the date stamp in the file name until rotate time? Default is false. | |
| rotatable | back to summary |
|---|---|
| protected boolean rotatable Should we rotate our log file? Default is true (like old behavior) | |
| rotationLastChecked | back to summary |
|---|---|
| private volatile long rotationLastChecked Instant when the log daily rotation was last checked. | |
| suffix | back to summary |
|---|---|
| protected volatile String suffix The suffix that is added to log file filenames. | |
| writer | back to summary |
|---|---|
| protected PrintWriter writer The PrintWriter to which we are currently logging, if any. | |
| AccessLogValve | back to summary |
|---|---|
| public AccessLogValve() | |
| backgroundProcess | back to summary |
|---|---|
| public synchronized void backgroundProcess() Overrides org. Implements org. Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.
| |
| close | back to summary |
|---|---|
| private synchronized void close(boolean rename) Close the currently open log file (if any)
| |
| getDirectory | back to summary |
|---|---|
public String getDirectory()
| |
| getDirectoryFile | back to summary |
|---|---|
| private File getDirectoryFile() | |
| getEncoding | back to summary |
|---|---|
| public String getEncoding() Return the character set name that is used to write the log file.
| |
| getFileDateFormat | back to summary |
|---|---|
public String getFileDateFormat()
| |
| getLogFile | back to summary |
|---|---|
| private File getLogFile(boolean useDateStamp) Create a File object based on the current log file name. Directories are created as needed but the underlying file is not created or opened.
| |
| getMaxDays | back to summary |
|---|---|
| public int getMaxDays() | |
| getPrefix | back to summary |
|---|---|
public String getPrefix()
| |
| getSuffix | back to summary |
|---|---|
public String getSuffix()
| |
| isBuffered | back to summary |
|---|---|
| public boolean isBuffered() Is the logging buffered. Usually buffering can increase performance.
| |
| isCheckExists | back to summary |
|---|---|
| public boolean isCheckExists() Check for file existence before logging.
| |
| isRenameOnRotate | back to summary |
|---|---|
| public boolean isRenameOnRotate() Should we defer inclusion of the date stamp in the file name until rotate time.
| |
| isRotatable | back to summary |
|---|---|
| public boolean isRotatable() Should we rotate the access log.
| |
| log | back to summary |
|---|---|
| public void log(CharArrayWriter message) Implements abstract org. Log the specified message to the log file, switching files if the date has changed since the previous log call.
| |
| open | back to summary |
|---|---|
| protected synchronized void open() Open the new log file for the date specified by | |
| restore | back to summary |
|---|---|
| private void restore() Move a current but rotated log file back to the unrotated one. Needed if date stamp inclusion is deferred to rotation time. | |
| rotate | back to summary |
|---|---|
| public void rotate() Rotate the log file if necessary. | |
| rotate | back to summary |
|---|---|
| public synchronized boolean rotate(String newFileName) Rename the existing log file to something else. Then open the old log file name up once again. Intended to be called by a JMX agent.
| |
| setBuffered | back to summary |
|---|---|
| public void setBuffered(boolean buffered) Set the value if the logging should be buffered
| |
| setCheckExists | back to summary |
|---|---|
| public void setCheckExists(boolean checkExists) Set whether to check for log file existence before logging.
| |
| setDirectory | back to summary |
|---|---|
| public void setDirectory(String directory) Set the directory in which we create log files.
| |
| setEncoding | back to summary |
|---|---|
| public void setEncoding(String encoding) Set the character set that is used to write the log file.
| |
| setFileDateFormat | back to summary |
|---|---|
| public void setFileDateFormat(String fileDateFormat) Set the date format date based log rotation.
| |
| setMaxDays | back to summary |
|---|---|
| public void setMaxDays(int maxDays) | |
| setPrefix | back to summary |
|---|---|
| public void setPrefix(String prefix) Set the log file prefix.
| |
| setRenameOnRotate | back to summary |
|---|---|
| public void setRenameOnRotate(boolean renameOnRotate) Set the value if we should defer inclusion of the date stamp in the file name until rotate time
| |
| setRotatable | back to summary |
|---|---|
| public void setRotatable(boolean rotatable) Configure whether the access log should be rotated.
| |
| setSuffix | back to summary |
|---|---|
| public void setSuffix(String suffix) Set the log file suffix.
| |
| startInternal | back to summary |
|---|---|
| protected void startInternal() throws LifecycleException Overrides org. Start this component and implement the requirements of
| |
| stopInternal | back to summary |
|---|---|
| protected void stopInternal() throws LifecycleException Overrides org. Stop this component and implement the requirements of
| |