com.bitfactoryinc.logging
Class Logger
java.lang.Object
|
+--com.bitfactoryinc.logging.Logger
- Direct Known Subclasses:
- CompositeLogger, EmailLogger, FileLogger, InsistentLogger, MemoryLogger, PrintStreamLogger, SerialLogger, SimpleSocketLogger
- public abstract class Logger
- extends java.lang.Object
- implements LoggingConstants
Concrete subclasses of this abstract class do the actual logging of information
to their respective "logs."
Subclasses that simply write a String to a log need only override writeToLog(String).
Subclasses that do a little more processing may prefer to override doLog(LogEntry).
In general, users of the various Logger subclasses need to be aware of only the
public log*(Object anItemToLog) and log*(Object aCategory, Object anItemToLog) methods
(where * is one of the severities, such as logInfo( "This is information" ) ).
You can log any Object, and it's toString() will be used in the LogEntry. Optionally, you
can use categories to distinguish various types of items being logged. These would usually
be Strings, but can be any Object. e.g. To log all database related itmes, you could
do something like logWarning("DB System", "Cannot connect to DB"); where you categorize
all database logs with "DB System". A LogEntryCatagegoryFilter subclass could optionally
be used to log only database related items.
application - This optional String represents information that is application-wide.
It might be a user name, or it might be the name of the application.
- See Also:
LogEntryCategoryFilter,
LogEntryAllowCategoryFilter,
LogEntryDisallowCategoryFilter
|
Method Summary |
protected boolean |
doLog(LogEntry aLogEntry)
We're past filtering at this point. |
java.lang.String |
getApplication()
|
static java.lang.Class |
getDefaultFilterClass()
|
static java.lang.Class |
getDefaultFormatterClass()
|
LogEntryFilter |
getFilter()
|
LogEntryFormatter |
getFormatter()
|
int |
getSeverityThreshold()
Return the filter's severity threshold |
boolean |
isEnabled()
|
void |
log(int aSeverity,
java.lang.Object anObject)
|
void |
log(int aSeverity,
java.lang.Object aCategory,
java.lang.Object anObject)
|
protected boolean |
log(LogEntry aLogEntry)
|
void |
logCritical(java.lang.Object anObject)
|
void |
logCritical(java.lang.Object aCategory,
java.lang.Object aMessage)
|
void |
logDebug(java.lang.Object anObject)
|
void |
logDebug(java.lang.Object aCategory,
java.lang.Object anObject)
|
void |
logError(java.lang.Object anObject)
|
void |
logError(java.lang.Object aCategory,
java.lang.Object anObject)
|
void |
logFatal(java.lang.Object anObject)
|
void |
logFatal(java.lang.Object aCategory,
java.lang.Object anObject)
|
void |
logInfo(java.lang.Object anObject)
|
void |
logInfo(java.lang.Object aCategory,
java.lang.Object anObject)
|
void |
logStatus(java.lang.Object anObject)
|
void |
logStatus(java.lang.Object aCategory,
java.lang.Object anObject)
|
void |
logWarning(java.lang.Object anObject)
|
void |
logWarning(java.lang.Object aCategory,
java.lang.Object anObject)
|
void |
setApplication(java.lang.String newApplication)
|
private void |
setDefaultFilter()
|
static void |
setDefaultFilterClass(java.lang.Class newDefaultFilterClass)
|
private void |
setDefaultFormatter()
|
static void |
setDefaultFormatterClass(java.lang.Class newDefaultFormatterClass)
|
void |
setEnabled(boolean newEnabled)
|
void |
setFilter(LogEntryFilter newFilter)
|
void |
setFormatter(LogEntryFormatter newFormatter)
|
void |
setSeverityThreshold(int aSeverityThreshold)
Set the filter's ceverity threshold |
private boolean |
shouldLog(LogEntry aLogEntry)
Return true if the receiver is enabled and the receiver's filter says aLogEntry should be logged |
protected boolean |
writeToLog(java.lang.String s)
Subclasse can override this method if they want to simply write a String to their log. |
| Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
application
private java.lang.String application
enabled
private boolean enabled
filter
private LogEntryFilter filter
formatter
private LogEntryFormatter formatter
defaultFormatterClass
private static java.lang.Class defaultFormatterClass
defaultFilterClass
private static java.lang.Class defaultFilterClass
Logger
public Logger()
doLog
protected boolean doLog(LogEntry aLogEntry)
- We're past filtering at this point. Now it's time to really log aLogEntry.
Subclasses might want to do something more interesting and override this method.
getApplication
public java.lang.String getApplication()
getDefaultFilterClass
public static java.lang.Class getDefaultFilterClass()
getDefaultFormatterClass
public static java.lang.Class getDefaultFormatterClass()
getFilter
public LogEntryFilter getFilter()
getFormatter
public LogEntryFormatter getFormatter()
getSeverityThreshold
public int getSeverityThreshold()
- Return the filter's severity threshold
isEnabled
public boolean isEnabled()
log
public final void log(int aSeverity,
java.lang.Object anObject)
log
public final void log(int aSeverity,
java.lang.Object aCategory,
java.lang.Object anObject)
log
protected final boolean log(LogEntry aLogEntry)
logCritical
public final void logCritical(java.lang.Object anObject)
logCritical
public final void logCritical(java.lang.Object aCategory,
java.lang.Object aMessage)
logDebug
public final void logDebug(java.lang.Object anObject)
logDebug
public final void logDebug(java.lang.Object aCategory,
java.lang.Object anObject)
logError
public final void logError(java.lang.Object anObject)
logError
public final void logError(java.lang.Object aCategory,
java.lang.Object anObject)
logFatal
public final void logFatal(java.lang.Object anObject)
logFatal
public final void logFatal(java.lang.Object aCategory,
java.lang.Object anObject)
logInfo
public final void logInfo(java.lang.Object anObject)
logInfo
public final void logInfo(java.lang.Object aCategory,
java.lang.Object anObject)
logStatus
public final void logStatus(java.lang.Object anObject)
logStatus
public final void logStatus(java.lang.Object aCategory,
java.lang.Object anObject)
logWarning
public final void logWarning(java.lang.Object anObject)
logWarning
public final void logWarning(java.lang.Object aCategory,
java.lang.Object anObject)
setApplication
public void setApplication(java.lang.String newApplication)
setDefaultFilter
private void setDefaultFilter()
setDefaultFilterClass
public static void setDefaultFilterClass(java.lang.Class newDefaultFilterClass)
setDefaultFormatter
private void setDefaultFormatter()
setDefaultFormatterClass
public static void setDefaultFormatterClass(java.lang.Class newDefaultFormatterClass)
setEnabled
public void setEnabled(boolean newEnabled)
setFilter
public void setFilter(LogEntryFilter newFilter)
setFormatter
public void setFormatter(LogEntryFormatter newFormatter)
setSeverityThreshold
public void setSeverityThreshold(int aSeverityThreshold)
- Set the filter's ceverity threshold
shouldLog
private final boolean shouldLog(LogEntry aLogEntry)
- Return true if the receiver is enabled and the receiver's filter says aLogEntry should be logged
writeToLog
protected boolean writeToLog(java.lang.String s)
- Subclasse can override this method if they want to simply write a String to their log.
Return true for successful processing of the log, false otherwise.