org.ibisph.util
Class Logger

java.lang.Object
  extended by org.ibisph.util.Logger

public class Logger
extends java.lang.Object

Title: Description: Simple message/exception logger that sends output to STDOUT and/or a specified log file. Company: STG

Version:
1.5
Author:
Garth Braithwaite

Field Summary
protected static java.lang.String baseLogFilename
          The log filename to use if none is specified in /dss/dss.properties.
static int CRITICAL_ERROR
          Severity value for high priority errors.
protected static int currentLogFileNumber
           
protected static long currentLogFileSize
           
static int DATABASE_ERROR
          Severity value for critical errors.
protected static java.util.Date date
           
protected static java.text.DateFormat dateFormat
           
static int DEBUG_MSG
           
protected static int fileLogLevel
           
static int HIGH_SEVERITY_ERROR
          Severity value for user specific errors.
static int INFO_MSG
          Severity value for debug messages.
protected static java.io.PrintStream logFile
           
protected static long logFileMaxSize
           
protected static java.lang.String logFilename
           
protected static java.io.FileOutputStream logFileStream
           
static int LOW_SEVERITY_ERROR
          Severity value for production informational messages.
protected static java.lang.String newLine
           
protected static int numLogFiles
           
protected static int sysOutLogLevel
           
static int UNKNOWN_ERROR
          Severity value for database problems.
static int USER_SPECIFIC_ERROR
          Severity value for low priority errors.
 
Constructor Summary
Logger()
           
Logger(java.lang.String baseLogFilename)
           
 
Method Summary
 void close()
           
 int getCurrentLogFileNumber()
           
 int getFileLogLevel()
           
 java.lang.String getFilenameForLog(int logNumber)
          Get the filename of the log with the specified number.
 long getLogFileMaxSize()
           
 java.lang.String getLogFilename()
           
 int getNumLogFiles()
           
 int getSysOutLogLevel()
           
static void log(java.lang.Object object, java.lang.String msg)
           
static void log(java.lang.Object object, java.lang.String msg, int severityLevel)
           
static void log(java.lang.Object object, java.lang.String msg, java.lang.Throwable error, int severityLevel)
          Log a message with the given severity.
static void log(java.lang.String msg)
           
static void log(java.lang.String msg, int severityLevel)
           
static void log(java.lang.String msg, java.lang.Throwable error, int severityLevel)
           
 boolean logFileExists(int logFileNum)
          Check to see if the log file represented by logFileNum exists yet.
 boolean open(java.lang.String baseLogFilename)
           
 void setBaseLogFilename(java.lang.String logFilenameBase)
           
 void setDateFormat(java.text.DateFormat dateFormat)
           
 void setFileLogLevel(int logLevel)
           
 void setFileLogLevel(java.lang.String logLevel)
           
 void setLogFileMaxSize(long size)
           
 void setLogFileMaxSize(java.lang.String size)
           
 void setNumLogFiles(int numberOfFiles)
           
 void setNumLogFiles(java.lang.String numberOfFiles)
           
 void setSysOutLogLevel(int logLevel)
           
 void setSysOutLogLevel(java.lang.String logLevel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_MSG

public static final int DEBUG_MSG
See Also:
Constant Field Values

INFO_MSG

public static final int INFO_MSG
Severity value for debug messages.

See Also:
Constant Field Values

LOW_SEVERITY_ERROR

public static final int LOW_SEVERITY_ERROR
Severity value for production informational messages.

See Also:
Constant Field Values

USER_SPECIFIC_ERROR

public static final int USER_SPECIFIC_ERROR
Severity value for low priority errors.

See Also:
Constant Field Values

HIGH_SEVERITY_ERROR

public static final int HIGH_SEVERITY_ERROR
Severity value for user specific errors.

See Also:
Constant Field Values

CRITICAL_ERROR

public static final int CRITICAL_ERROR
Severity value for high priority errors.

See Also:
Constant Field Values

DATABASE_ERROR

public static final int DATABASE_ERROR
Severity value for critical errors.

See Also:
Constant Field Values

UNKNOWN_ERROR

public static final int UNKNOWN_ERROR
Severity value for database problems.

See Also:
Constant Field Values

baseLogFilename

protected static java.lang.String baseLogFilename
The log filename to use if none is specified in /dss/dss.properties.


logFilename

protected static java.lang.String logFilename

logFileStream

protected static java.io.FileOutputStream logFileStream

logFile

protected static java.io.PrintStream logFile

dateFormat

protected static java.text.DateFormat dateFormat

date

protected static java.util.Date date

currentLogFileNumber

protected static int currentLogFileNumber

currentLogFileSize

protected static long currentLogFileSize

numLogFiles

protected static int numLogFiles

logFileMaxSize

protected static long logFileMaxSize

fileLogLevel

protected static int fileLogLevel

sysOutLogLevel

protected static int sysOutLogLevel

newLine

protected static java.lang.String newLine
Constructor Detail

Logger

public Logger()

Logger

public Logger(java.lang.String baseLogFilename)
Method Detail

open

public boolean open(java.lang.String baseLogFilename)

close

public void close()

getFileLogLevel

public int getFileLogLevel()

getSysOutLogLevel

public int getSysOutLogLevel()

getLogFilename

public java.lang.String getLogFilename()

getNumLogFiles

public int getNumLogFiles()

getCurrentLogFileNumber

public int getCurrentLogFileNumber()

getLogFileMaxSize

public long getLogFileMaxSize()

getFilenameForLog

public java.lang.String getFilenameForLog(int logNumber)
Get the filename of the log with the specified number.

Parameters:
logNumber - The number of the log file. This must be greater than zero and less than or equal to the number of log files that the server is keeping. See Logger.getNumberOfLogFiles().
Returns:
A String holding the filename that would be used for a log file with that number. Note that this does not necessarily mean that such a log file has been created yet. This method will return null if logNumber is invalid.

logFileExists

public boolean logFileExists(int logFileNum)
Check to see if the log file represented by logFileNum exists yet.

Parameters:
logFileNum - The number of the log file to check.
Returns:
A boolean value of true if the file exists or false otherwise.

setFileLogLevel

public void setFileLogLevel(int logLevel)

setSysOutLogLevel

public void setSysOutLogLevel(int logLevel)

setLogFileMaxSize

public void setLogFileMaxSize(long size)

setNumLogFiles

public void setNumLogFiles(int numberOfFiles)

setBaseLogFilename

public void setBaseLogFilename(java.lang.String logFilenameBase)

setDateFormat

public void setDateFormat(java.text.DateFormat dateFormat)

setFileLogLevel

public void setFileLogLevel(java.lang.String logLevel)

setSysOutLogLevel

public void setSysOutLogLevel(java.lang.String logLevel)

setLogFileMaxSize

public void setLogFileMaxSize(java.lang.String size)

setNumLogFiles

public void setNumLogFiles(java.lang.String numberOfFiles)

log

public static void log(java.lang.Object object,
                       java.lang.String msg,
                       java.lang.Throwable error,
                       int severityLevel)
Log a message with the given severity. If the severity level is greater than or equal to notificationLevel then an email message will be sent to all administrator email addresses specified in dss.properties.

Parameters:
msg - String holding the message to be logged.
error - Optional Throwable that contains a throwable/exception to be logged.
severityLevel - Optional integer flag indicating the severity level of the error.

log

public static void log(java.lang.String msg,
                       java.lang.Throwable error,
                       int severityLevel)

log

public static void log(java.lang.Object object,
                       java.lang.String msg,
                       int severityLevel)

log

public static void log(java.lang.String msg,
                       int severityLevel)

log

public static void log(java.lang.Object object,
                       java.lang.String msg)

log

public static void log(java.lang.String msg)