com.samskivert.util
Class AuditLogger

java.lang.Object
  extended by com.samskivert.util.AuditLogger

public class AuditLogger
extends Object

Used by various services to generate audit logs which can be useful for auditing, debugging and other logly necessities. The audit logger automatically rolls over its logs at midnight to facilitate the collection, processing and possible archiving of the logs.


Field Summary
protected  SimpleDateFormat _dayFormat
          Used to format log file suffixes.
protected  String _dayStamp
          The daystamp of the log file we're currently writing to.
protected  SimpleDateFormat _format
          Used to format timestamps.
protected  FieldPosition _fpos
          Annoying parameter required by the Format.format() method that appends to a string buffer.
protected  File _logPath
          The path to our log file.
protected  PrintWriter _logWriter
          We actually write to this feller here.
protected  Interval _rollover
          The interval that rolls over the log file.
protected  Throttle _throttle
          Suppress freakouts if our log file becomes hosed.
protected  int _throttled
          Used to count the number of throttled messages for reporting.
protected static String TIMESTAMP_FORMAT
          Timestamp format used on all log messages.
protected static int TIMESTAMP_LENGTH
          The length of the timestamp format.
 
Constructor Summary
AuditLogger(File fullpath)
          Creates an audit logger that logs to the specified file.
AuditLogger(File path, String filename)
          Creates an audit logger that logs to the specified file.
 
Method Summary
protected  void checkRollOver()
          Check to see if it's time to roll over the log file.
 void close()
          Closes this audit log (generally only done when the server is shutting down.
 void log(String message)
          Writes the supplied message to the log, prefixed by a date and timestamp.
protected  void openLog(boolean freakout)
          Opens our log file, sets up our print writer and writes a message to it indicating that it was opened.
protected  void scheduleNextRolloverCheck()
          Schedule the next check to see if we should roll the logs over.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rollover

protected Interval _rollover
The interval that rolls over the log file.


_logPath

protected File _logPath
The path to our log file.


_logWriter

protected PrintWriter _logWriter
We actually write to this feller here.


_throttle

protected Throttle _throttle
Suppress freakouts if our log file becomes hosed.


_throttled

protected int _throttled
Used to count the number of throttled messages for reporting.


_dayStamp

protected String _dayStamp
The daystamp of the log file we're currently writing to.


_dayFormat

protected SimpleDateFormat _dayFormat
Used to format log file suffixes.


_format

protected SimpleDateFormat _format
Used to format timestamps.


_fpos

protected FieldPosition _fpos
Annoying parameter required by the Format.format() method that appends to a string buffer.


TIMESTAMP_FORMAT

protected static final String TIMESTAMP_FORMAT
Timestamp format used on all log messages.

See Also:
Constant Field Values

TIMESTAMP_LENGTH

protected static final int TIMESTAMP_LENGTH
The length of the timestamp format.

Constructor Detail

AuditLogger

public AuditLogger(File path,
                   String filename)
Creates an audit logger that logs to the specified file.


AuditLogger

public AuditLogger(File fullpath)
Creates an audit logger that logs to the specified file.

Method Detail

log

public void log(String message)
Writes the supplied message to the log, prefixed by a date and timestamp. A newline will be appended to the message.


close

public void close()
Closes this audit log (generally only done when the server is shutting down.


openLog

protected void openLog(boolean freakout)
Opens our log file, sets up our print writer and writes a message to it indicating that it was opened.


checkRollOver

protected void checkRollOver()
Check to see if it's time to roll over the log file.


scheduleNextRolloverCheck

protected void scheduleNextRolloverCheck()
Schedule the next check to see if we should roll the logs over.



Copyright © 2000-2008 Michael Bayne. All Rights Reserved.