org.norther.tammi.core.logger
Class AbstractLogger

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.config.DefaultConfigurable
          extended by org.norther.tammi.core.config.DefaultConfigurableFactory
              extended by org.norther.tammi.core.logger.AbstractLogger
All Implemented Interfaces:
Serializable, EventListener, NotificationBroadcaster, NotificationEmitter, Localizer, TraceListener, Manageable, MBeanDelegate, ObjectFactory, Refreshable, CacheClient, Configurable, ConfigurableFactory, ResourceMap, Logger
Direct Known Subclasses:
AbstractThreadedLogger

public abstract class AbstractLogger
extends DefaultConfigurableFactory
implements Logger

An abstract implementation of Logger.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
protected static boolean traceOn
          The trace flag.
 
Fields inherited from class org.norther.tammi.core.config.DefaultConfigurable
MODIFIED, SYNCHRONIZED, UNMODIFIED
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.logger.Logger
ACCESS, DEBUG, ERROR, FATAL, INFO, NONE, TRACE, WARN, WARNING
 
Fields inherited from interface org.norther.tammi.acorn.locale.Localizer
ANY_NAME
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
AbstractLogger()
          Contructs a new logger.
 
Method Summary
protected  void activate(LoggerListener log, String name)
          Activates the specified logger listener.
 void addAppender(Object log, Object appender)
          Adds a new appender for the specified logger.
 void addFilter(String className)
          Adds an exception filter.
 void clearAppenders(Object log)
          Clears appenders of the specified logger.
 void clearCached()
          Clears all cached entries without notifying.
 void clearFilters()
          Clears all exception filters.
 void clearResourceBundleNames()
          Clears all resource bundle names.
 void expireCached(long timestamp)
          Expires all cached entries notifying them about expiration.
 void expireFraction(long timestamp, float fraction)
          Expires the specified fraction of cached entries notifying them about expiration.
 void flush()
          Flushes queued log entries.
 boolean getAdditivity(Object log)
          Gets the additivity of the specified logger.
protected  Object getAnonymousLogger(int level)
          Gets the logger for the specified level.
 String[] getAppenderNames(Object log)
          Gets appender names of the specified logger.
 int getBufferSize()
          Gets the log buffer size.
 ConcurrentMap getCache(boolean create)
          Gets and optionally creates the cache.
 String getDefaultBaseName()
          Gets the default base name.
 ObjectName getFallbackResourcesName()
          Gets the fallback resources of this map.
 String[] getFilters()
          Gets exception filters.
 Object getInstance(String className, ObjectName loader, Object[] params, String[] signature)
          Gets an instance of a named class using a specified class loader.
 int getLevel()
          Gets the root level.
 int getLevel(Object log)
          Gets the level of the specified logger.
 String getLocalizedMessage(Object msg)
          Gets a localized message for the default locale.
 String getLocalizedMessage(Object msg, Locale locale)
          Gets a localized message for the specified locale.
 String getLogClassName()
          Gets the log implementation class name.
 String getLoggerName(int level)
          Gets the logger name for the specified level.
protected  String getLoggerName(Object log)
          Gets the logger name for the specified log object.
protected abstract  Object getNativeLogger(String name)
          Gets a named native logger.
 String getPlugInBaseName(String key)
          Gets the base name of the resource bundle class associated with the specified plug-in key.
 int getPollingInterval()
          Gets the interval of polling new enries for logging.
 long getRefreshed()
          Gets the last refresh timestamp.
 LookupResourceBundle getResourceBundle(String baseName)
          Gets a resource bundle for the specified base name.
 LookupResourceBundle getResourceBundle(String baseName, Locale locale)
          Gets a resource bundle for the specified base name and locale.
 String getResourceBundleName(String qualifier)
          Gets the qualified resource bundle name.
 ObjectName getResourceFinderName()
          Gets the resource finder of this map.
 String getTimeZoneId()
          Gets the default time zone.
 boolean isCachingDisabled()
          Checks whether the caching is disabled.
 boolean isDefaultLogFactory()
          Checks whether a default log factory.
 boolean isLoaderSupported(String className)
          Checks if specified class loaders are supported for a named class.
 boolean isStackTrace()
          Gets the stack trace flag for all categories called through this logger instance.
 boolean isStaticTrace()
          Gets the trace flag for the static trace methods.
 boolean isSystemErrLogged()
          Checks if system err is to be logged by this logger.
 boolean isSystemOutLogged()
          Checks if system out is to be logged by this logger.
 void log(int level, long time, String msg, Object arg)
          Logs a message with a specific level, date and argument.
 void log(int level, long time, String msg, Object arg, Throwable cause)
          Logs a message with a specific level, date, argument and reason.
 void log(int level, Object msg)
          Logs a message with a specific level.
 void log(int level, String msg, Object arg)
          Logs a message with a specific level and argument.
 void log(int level, String msg, Object arg, Throwable reason)
          Logs a message with a specific level, argument and reason.
 void log(Object log, int level, long time, String msg, Object arg)
          Logs a message with a specific logger, level, date and argument.
 void log(Object log, int level, long time, String msg, Object arg, Throwable cause)
          Logs a message with a specific logger, level, date, argument and reason.
 void log(Object log, int level, Object msg)
          Logs a message with a specific logger and level.
 void log(Object log, int level, String msg, Object arg)
          Logs a message with a specific logger, level and argument.
 void log(Object log, int level, String msg, Object arg, Throwable cause)
          Logs a message with a specific logger, level, argument and reason.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
protected abstract  void push(LogEntry entry)
          Pushes a log entry into a queue.
 Set qualifierSet()
          Returns a read-only set of resource qualifiers.
 void refresh()
          Refreshes the MBean.
 void removeAppender(Object log, String appender)
          Removes an appender from the specified logger.
 void removeCache()
          Removes the cache.
 void removeFilter(String className)
          Removes an exception filter.
 void removeResourceBundleName(String qualifier)
          Removes the resource bundle name of the qualified name.
 Object resolveLocalizedObject(String name, String key)
          Resolves a localized object for the qualified name and key.
 Object resolveLocalizedObject(String name, String key, Locale locale)
          Resolves a localized object for the qualified name, key and locale.
 Object resolveLocalizedResource(String name, String key)
          Resolves a localized resource for the qualified name and key.
 Object resolveLocalizedResource(String name, String key, Locale locale)
          Resolves a localized resource for the qualified name, key and locale.
 String resolveLocalizedString(String name, String key)
          Resolves a localized string for the qualified name and key.
 String resolveLocalizedString(String name, String key, Locale locale)
          Resolves a localized string for the qualified name, key and locale.
 String[] resolveLocalizedStrings(String name, String key)
          Resolves a localized string array for the qualified name and key.
 String[] resolveLocalizedStrings(String name, String key, Locale locale)
          Resolves a localized string array for the qualified name, key and locale.
 LookupResourceBundle resolveResourceBundle(String name)
          Resolves a resource bundle for the qualified name.
 LookupResourceBundle resolveResourceBundle(String name, Locale locale)
          Resolves a resource bundle for the qualified name and locale.
 String resolveResourceBundleName(String name)
          Resolves a resource bundle name for the qualified name.
 void setAdditivity(Object log, boolean additivity)
          Sets the additivity of the specified logger.
 void setBufferSize(int size)
          Sets the log buffer size.
 void setCachingDisabled(boolean flag)
          Sets the caching disabled flag.
 void setDefaultBaseName(String baseName)
          Sets the default base name.
 void setDefaultLogFactory(boolean flag)
          Sets whether a default log factory.
 void setFallbackResourcesName(ObjectName finder)
          Sets the fallback resources of this map.
 void setFilters(String[] classNames)
          Sets exception filters.
 void setLevel(int level)
          Sets the root level.
 void setLevel(Object log, int level)
          Sets the level of the specified logger.
 void setLevelAsString(Object log, String level)
          Sets the level of the specified logger as a string.
 void setLevelAsString(String level)
          Sets the root level as a string.
 void setLogClassName(String className)
          Sets the log implementation class name.
 void setLoggerName(int level, String name)
          Sets the logger name for the specified level.
 void setPollingInterval(int msecs)
          Sets the interval of polling new enries for logging.
 void setResourceBundleName(String qualifier, String baseName)
          Sets the resource bundle name of the qualified name.
 void setResourceFinderName(ObjectName finder)
          Sets the resource finder of this map.
 void setStackTrace(boolean flag)
          Sets the stack trace flag for all categories called through this logger instance.
 void setStaticTrace(boolean flag)
          Sets the trace flag for static trace methods.
 void setSystemErrLogged(boolean flag)
          Sets if system err if to be logged by this logger.
 void setSystemOutLogged(boolean flag)
          Sets if system out is to be logged by this logger.
 void setTimeZoneId(String zone)
          Sets the default time zone.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.core.config.DefaultConfigurableFactory
getInstance, getInstance, getInstance
 
Methods inherited from class org.norther.tammi.core.config.DefaultConfigurable
addProperty, addProperty, clearProperties, containsProperty, getConfigKey, getConfiguration, getModifiedState, getProperties, getProperty, getPropertyFilePath, indexOfProperty, loadConfiguration, loadConfiguration, loadConfiguration, modified, propertyMap, propertyMap, removeProperty, removeProperty, setConfigKey, setModifiedState, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, storeProperties
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.logger.Logger
getLoggerClassName, isLog, isLog, release
 
Methods inherited from interface org.norther.tammi.core.base.ObjectFactory
getInstance, getInstance, getInstance
 
Methods inherited from interface org.norther.tammi.core.config.Configurable
addProperty, addProperty, clearProperties, containsProperty, getConfigKey, getProperties, getProperty, getPropertyFilePath, indexOfProperty, propertyMap, propertyMap, removeProperty, removeProperty, setConfigKey, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, storeProperties
 

Field Detail

traceOn

protected static boolean traceOn
The trace flag.

Constructor Detail

AbstractLogger

public AbstractLogger()
Contructs a new logger.

Method Detail

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable
Overrides:
postmanaged in class Adaptee

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class Adaptee
Throws:
Exception - if the adaptee refused to be unmanaged.

isStaticTrace

public boolean isStaticTrace()
Description copied from interface: Logger
Gets the trace flag for the static trace methods.

Specified by:
isStaticTrace in interface Logger
Returns:
true, if static trace is on.

setStaticTrace

public void setStaticTrace(boolean flag)
Description copied from interface: Logger
Sets the trace flag for static trace methods.

Specified by:
setStaticTrace in interface Logger
Parameters:
flag - the static trace on/off flag.

isStackTrace

public boolean isStackTrace()
Description copied from interface: Logger
Gets the stack trace flag for all categories called through this logger instance.

Specified by:
isStackTrace in interface Logger
Returns:
true, if stack trace in on.

setStackTrace

public void setStackTrace(boolean flag)
Description copied from interface: Logger
Sets the stack trace flag for all categories called through this logger instance.

Specified by:
setStackTrace in interface Logger
Parameters:
flag - the stack trace on/off flag.

getBufferSize

public int getBufferSize()
Description copied from interface: Logger
Gets the log buffer size.

Specified by:
getBufferSize in interface Logger
Returns:
the buffer size as a number of log entries.

setBufferSize

public void setBufferSize(int size)
Description copied from interface: Logger
Sets the log buffer size.

Specified by:
setBufferSize in interface Logger
Parameters:
size - the buffer size as a number of log entries.

getPollingInterval

public int getPollingInterval()
Description copied from interface: Logger
Gets the interval of polling new enries for logging.

Specified by:
getPollingInterval in interface Logger
Returns:
the polling interval in msecs.

setPollingInterval

public void setPollingInterval(int msecs)
Description copied from interface: Logger
Sets the interval of polling new enries for logging.

Specified by:
setPollingInterval in interface Logger
Parameters:
msecs - the polling interval in msecs.

getTimeZoneId

public String getTimeZoneId()
Description copied from interface: Logger
Gets the default time zone.

Specified by:
getTimeZoneId in interface Logger
Returns:
the default time zone of log entries.

setTimeZoneId

public void setTimeZoneId(String zone)
Description copied from interface: Logger
Sets the default time zone.

Specified by:
setTimeZoneId in interface Logger
Parameters:
zone - the default time zone of log entries.

isDefaultLogFactory

public boolean isDefaultLogFactory()
Description copied from interface: Logger
Checks whether a default log factory.

Specified by:
isDefaultLogFactory in interface Logger
Returns:
true if a default factory, false otherwise.

setDefaultLogFactory

public void setDefaultLogFactory(boolean flag)
Description copied from interface: Logger
Sets whether a default log factory.

Specified by:
setDefaultLogFactory in interface Logger
Parameters:
flag - true if a default factory, false otherwise.

getLogClassName

public String getLogClassName()
Description copied from interface: Logger
Gets the log implementation class name.

Specified by:
getLogClassName in interface Logger
Returns:
the log class name.

setLogClassName

public void setLogClassName(String className)
Description copied from interface: Logger
Sets the log implementation class name.

Specified by:
setLogClassName in interface Logger
Parameters:
className - the log class name.

getLoggerName

public String getLoggerName(int level)
Description copied from interface: Logger
Gets the logger name for the specified level.

Specified by:
getLoggerName in interface Logger
Parameters:
level - the level.
Returns:
the logger or null for root.

setLoggerName

public void setLoggerName(int level,
                          String name)
Description copied from interface: Logger
Sets the logger name for the specified level.

Specified by:
setLoggerName in interface Logger
Parameters:
level - the level.
name - the logger name.

getLevel

public int getLevel()
Description copied from interface: Logger
Gets the root level.

Specified by:
getLevel in interface Logger
Returns:
the level.

setLevel

public void setLevel(int level)
Description copied from interface: Logger
Sets the root level.

Specified by:
setLevel in interface Logger
Parameters:
level - the level.

setLevelAsString

public void setLevelAsString(String level)
Description copied from interface: Logger
Sets the root level as a string.

Specified by:
setLevelAsString in interface Logger
Parameters:
level - the level as a string.

getLevel

public int getLevel(Object log)
Description copied from interface: Logger
Gets the level of the specified logger.

Specified by:
getLevel in interface Logger
Parameters:
log - the logger.
Returns:
the level.

setLevel

public void setLevel(Object log,
                     int level)
Description copied from interface: Logger
Sets the level of the specified logger.

Specified by:
setLevel in interface Logger
Parameters:
log - the logger.
level - the level.

setLevelAsString

public void setLevelAsString(Object log,
                             String level)
Description copied from interface: Logger
Sets the level of the specified logger as a string.

Specified by:
setLevelAsString in interface Logger
Parameters:
log - the logger.
level - the level as a string.

getAdditivity

public boolean getAdditivity(Object log)
Description copied from interface: Logger
Gets the additivity of the specified logger.

Specified by:
getAdditivity in interface Logger
Parameters:
log - the logger.
Returns:
the additivity.

setAdditivity

public void setAdditivity(Object log,
                          boolean additivity)
Description copied from interface: Logger
Sets the additivity of the specified logger.

Specified by:
setAdditivity in interface Logger
Parameters:
log - the logger.
additivity - the additivity.

addAppender

public void addAppender(Object log,
                        Object appender)
Description copied from interface: Logger
Adds a new appender for the specified logger.

Specified by:
addAppender in interface Logger
Parameters:
log - the logger.
appender - the appender class name.

getAppenderNames

public String[] getAppenderNames(Object log)
Description copied from interface: Logger
Gets appender names of the specified logger.

Specified by:
getAppenderNames in interface Logger
Parameters:
log - the logger.
Returns:
an array of appender names.

removeAppender

public void removeAppender(Object log,
                           String appender)
Description copied from interface: Logger
Removes an appender from the specified logger.

Specified by:
removeAppender in interface Logger
Parameters:
log - the logger.
appender - the appender name.

clearAppenders

public void clearAppenders(Object log)
Description copied from interface: Logger
Clears appenders of the specified logger.

Specified by:
clearAppenders in interface Logger
Parameters:
log - the logger.

getFilters

public String[] getFilters()
Description copied from interface: Logger
Gets exception filters.

Specified by:
getFilters in interface Logger
Returns:
an array of exception filters.

setFilters

public void setFilters(String[] classNames)
Description copied from interface: Logger
Sets exception filters.

Specified by:
setFilters in interface Logger
Parameters:
classNames - an array of exception filters.

addFilter

public void addFilter(String className)
Description copied from interface: Logger
Adds an exception filter.

Specified by:
addFilter in interface Logger
Parameters:
className - the class name of a filtered exception.

removeFilter

public void removeFilter(String className)
Description copied from interface: Logger
Removes an exception filter.

Specified by:
removeFilter in interface Logger
Parameters:
className - the class name of a filtered exception.

clearFilters

public void clearFilters()
Description copied from interface: Logger
Clears all exception filters.

Specified by:
clearFilters in interface Logger

log

public void log(int level,
                Object msg)
Description copied from interface: Logger
Logs a message with a specific level.

Specified by:
log in interface Logger
Parameters:
level - the level of the message.
msg - the message to log.

log

public void log(int level,
                String msg,
                Object arg)
Description copied from interface: Logger
Logs a message with a specific level and argument.

Specified by:
log in interface Logger
Parameters:
level - the level of the message.
msg - the message to log.
arg - the argument or cause.

log

public void log(int level,
                String msg,
                Object arg,
                Throwable reason)
Description copied from interface: Logger
Logs a message with a specific level, argument and reason.

Specified by:
log in interface Logger
Parameters:
level - the level of the message.
msg - the message to log.
arg - the argument.
reason - the cause.

log

public void log(int level,
                long time,
                String msg,
                Object arg)
Description copied from interface: Logger
Logs a message with a specific level, date and argument.

Specified by:
log in interface Logger
Parameters:
level - the level of the message.
time - the time of the event.
msg - the message to log.
arg - the argument or cause.

log

public void log(int level,
                long time,
                String msg,
                Object arg,
                Throwable cause)
Description copied from interface: Logger
Logs a message with a specific level, date, argument and reason.

Specified by:
log in interface Logger
Parameters:
level - the level of the message.
time - the time of the event.
msg - the message to log.
arg - the argument.
cause - the cause.

log

public void log(Object log,
                int level,
                Object msg)
Description copied from interface: Logger
Logs a message with a specific logger and level.

Specified by:
log in interface Logger
Parameters:
log - the logger.
level - the level of the message.
msg - the message to log.

log

public void log(Object log,
                int level,
                String msg,
                Object arg)
Description copied from interface: Logger
Logs a message with a specific logger, level and argument.

Specified by:
log in interface Logger
Parameters:
log - the logger.
level - the level of the message.
msg - the message to log.
arg - the argument or cau