com.sun.star.util.logging
Class Logger

java.lang.Object
  |
  +--com.sun.star.util.logging.Logger

public class Logger
extends java.lang.Object
implements ILogger

A Logger object is used to log messages for a specific system or application component. Loggers are normally named, using a hierarchical dot-separated namespace. Logger names can be arbitrary strings, but they should normally be based on the package name or class name of the logged component, such as java.net or javax.swing.

Logger objects are obtained by a call to the getLogger factory method. This will either create a new Logger or return a suitable existing Logger.

Logging messages will be forwarded to registered Handler objects, which can forward the messages to a variety of destinations, including consoles, files, OS logs, etc.

On each logging call the Logger initially performs a cheap check of the request level (e.g. SEVERE or FINE) against a log level maintained by the logger. If the request level is lower than the log level, the logging call returns immediately.

The log level is is read from the properties in the logging configuration file, as described in the description of the LogManager class.

Formatting is the responsibility of the output Handler, which will typically call a Formatter/Layout.

Note that formatting need not occur synchronously. It may be delayed until a LogRecord is actually written to an external sink.

All methods on Logger are multi-thread safe.


Inner Class Summary
 class Logger.LoggerPropertyChangeListener
           
 
Field Summary
protected  Logger.LoggerPropertyChangeListener m_aListener
           
protected static java.util.Hashtable m_aLoggerHash
           
protected  ILogger m_aWrapper
           
protected  java.lang.String m_sName
           
 
Constructor Summary
protected Logger(ILogger aLogger)
           
 
Method Summary
 void config(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Log a CONFIG message, specifying source class and method.
protected static ILogger createWrapper(java.lang.String sName)
           
 void fine(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Log a FINE message, specifying source class and method.
 void finer(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Log a FINER message, specifying source class and method.
 void finest(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Log a FINEST message, specifying source class and method.
 ILogger getConfiguredInstance()
           
static Logger getLogger(java.lang.String sName)
          Find or create a logger for a named subsystem.
 void info(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Log an INFO message, specifying source class and method.
 boolean isLoggable(Level level)
          Check if a message of the given level would actually be logged by this logger.
protected static ILogger loadClassLogger(java.lang.String sName, java.lang.String sClass)
           
protected  void reconfigure()
           
 void severe(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Log a SEVERE message, specifying source class and method.
 void warning(java.lang.String sourceClass, java.lang.String sourceMethod, java.lang.String msg)
          Log a WARNING message, specifying source class and method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_aLoggerHash

protected static java.util.Hashtable m_aLoggerHash

m_aWrapper

protected ILogger m_aWrapper

m_sName

protected java.lang.String m_sName

m_aListener

protected Logger.LoggerPropertyChangeListener m_aListener
Constructor Detail

Logger

protected Logger(ILogger aLogger)
Method Detail

getLogger

public static Logger getLogger(java.lang.String sName)
Find or create a logger for a named subsystem. If a logger has already been created with the given name it is returned. Otherwise a new logger is created.

If a new logger is created its log level will be configured based on the LogManager configuration and it will configured to send logging output to all global output Handlers.

Parameters:
name - A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as java.net or javax.swing
Returns:
a suitable Logger

createWrapper

protected static ILogger createWrapper(java.lang.String sName)

loadClassLogger

protected static ILogger loadClassLogger(java.lang.String sName,
                                         java.lang.String sClass)

reconfigure

protected void reconfigure()

getConfiguredInstance

public ILogger getConfiguredInstance()
Specified by:
getConfiguredInstance in interface ILogger

isLoggable

public boolean isLoggable(Level level)
Check if a message of the given level would actually be logged by this logger.
Specified by:
isLoggable in interface ILogger
Parameters:
level - a message logging level
Returns:
true if the given message level is currently being logged.

severe

public void severe(java.lang.String sourceClass,
                   java.lang.String sourceMethod,
                   java.lang.String msg)
Log a SEVERE message, specifying source class and method.

If the logger is currently enabled for the SEVERE message level then the given message is forwarded to all the registered output Handler objects.

Specified by:
severe in interface ILogger
Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)

warning

public void warning(java.lang.String sourceClass,
                    java.lang.String sourceMethod,
                    java.lang.String msg)
Log a WARNING message, specifying source class and method.

If the logger is currently enabled for the WARNING message level then the given message is forwarded to all the registered output Handler objects.

Specified by:
warning in interface ILogger
Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)

info

public void info(java.lang.String sourceClass,
                 java.lang.String sourceMethod,
                 java.lang.String msg)
Log an INFO message, specifying source class and method.

If the logger is currently enabled for the INFO message level then the given message is forwarded to all the registered output Handler objects.

Specified by:
info in interface ILogger
Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)

config

public void config(java.lang.String sourceClass,
                   java.lang.String sourceMethod,
                   java.lang.String msg)
Log a CONFIG message, specifying source class and method.

If the logger is currently enabled for the CONFIG message level then the given message is forwarded to all the registered output Handler objects.

Specified by:
config in interface ILogger
Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)

fine

public void fine(java.lang.String sourceClass,
                 java.lang.String sourceMethod,
                 java.lang.String msg)
Log a FINE message, specifying source class and method.

If the logger is currently enabled for the FINE message level then the given message is forwarded to all the registered output Handler objects.

Specified by:
fine in interface ILogger
Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)

finer

public void finer(java.lang.String sourceClass,
                  java.lang.String sourceMethod,
                  java.lang.String msg)
Log a FINER message, specifying source class and method.

If the logger is currently enabled for the FINER message level then the given message is forwarded to all the registered output Handler objects.

Specified by:
finer in interface ILogger
Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)

finest

public void finest(java.lang.String sourceClass,
                   java.lang.String sourceMethod,
                   java.lang.String msg)
Log a FINEST message, specifying source class and method.

If the logger is currently enabled for the FINEST message level then the given message is forwarded to all the registered output Handler objects.

Specified by:
finest in interface ILogger
Parameters:
sourceClass - name of class that issued the logging request
sourceMethod - name of method that issued the logging request
msg - The string message (or a key in the message catalog)