org.esa.beam.util.logging
Class BeamLogManager

java.lang.Object
  extended by org.esa.beam.util.logging.BeamLogManager

public class BeamLogManager
extends Object

This class is the central manager class for logging. It exposes a set of convenience methods for the initializytion and configuration of the logging framework.


Constructor Summary
BeamLogManager()
           
 
Method Summary
static void configureSystemLogger(Formatter formatter, boolean consoleEcho)
          Configures the system logger using the given formatter and installs an optional console handler.
static BeamFormatter createFormatter(String appName, String appVersion, String copyrightInfo)
          Crates a logging formatter.
static String createLogHeader(String appName, String appVersion, String copyrightInfo)
           
static void ensureLogPathFromPatternExists(String logPattern)
           
static String getLogFilePattern(File outDir, String logFilenamePrefix)
          Gets a log file pattern for the specified output directory filname prefix.
static String getLogFilePattern(String logFilenamePrefix)
          Gets a log file pattern for the given filname prefix.
static CacheHandler getRegisteredCacheHandler()
          Retrieves the first registered CacheHandler in the list of handlers attached to the system logger.
static Logger getSystemLogger()
          Gets the system logger determined by the name returned by the getSystemLoggerName method.
static String getSystemLoggerName()
          Gets the name of the system logger.
static void removeRootLoggerHandlers()
          Removes all logging handlers from the root logger.
static void setSystemLoggerName(String systemLoggerName)
          Sets the name of the system logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeamLogManager

public BeamLogManager()
Method Detail

getSystemLoggerName

public static String getSystemLoggerName()
Gets the name of the system logger. This method is used to determine the system logger used by all low-level classes of the BEAM API. The logger name should always start with "beam.". High-level application classes should always use loggers with the name "beam.app-name".

Returns:
the name of the system logger, must not be null
See Also:
setSystemLoggerName(java.lang.String), getSystemLogger()

setSystemLoggerName

public static void setSystemLoggerName(String systemLoggerName)
Sets the name of the system logger. This method should be used by BEAM applications to register the name for the system logger which is used by all-low level classes of the BEAM API. The logger name should always start with "beam.".

Parameters:
systemLoggerName - the name of the system logger, must not be null
See Also:
getSystemLoggerName(), getSystemLogger()

getSystemLogger

public static Logger getSystemLogger()
Gets the system logger determined by the name returned by the getSystemLoggerName method. Other loggers are obtained using the standard Java 1.4 method java.util.logging.Logger.getLogger(name). BEAM logging works as follows:

Returns:
the system logger
See Also:
getSystemLoggerName(), setSystemLoggerName(java.lang.String)

getLogFilePattern

public static String getLogFilePattern(String logFilenamePrefix)
Gets a log file pattern for the given filname prefix. The pattern returned includes an absolute path the BEAM's system log directory $BEAM_INSTALL_DIR$/log and a filename created from the given log filename prefix. This pattern is used to create java.util.logging.FileHandler instances.

Parameters:
logFilenamePrefix - the log filename prefix
Returns:
a log file pattern for the given filname prefix
See Also:
getLogFilePattern(File, String)

getLogFilePattern

public static String getLogFilePattern(File outDir,
                                       String logFilenamePrefix)
Gets a log file pattern for the specified output directory filname prefix. The pattern returned includes the specified output directory and a filename created from the given log filename prefix. This pattern is used to create java.util.logging.FileHandler instances.

Parameters:
logFilenamePrefix - the log filename prefix
Returns:
a log file pattern for the given filname prefix
See Also:
getLogFilePattern(String)

configureSystemLogger

public static void configureSystemLogger(Formatter formatter,
                                         boolean consoleEcho)
Configures the system logger using the given formatter and installs an optional console handler.

Parameters:
formatter - the formatter to be used
consoleEcho - if true, a console handler will be installed

getRegisteredCacheHandler

public static CacheHandler getRegisteredCacheHandler()
Retrieves the first registered CacheHandler in the list of handlers attached to the system logger.

Returns:
a CacheHandler

createFormatter

public static BeamFormatter createFormatter(String appName,
                                            String appVersion,
                                            String copyrightInfo)
Crates a logging formatter.

Parameters:
appName - the application name
appVersion - the application version string
copyrightInfo - the application copyright information
Returns:
a formatter

removeRootLoggerHandlers

public static void removeRootLoggerHandlers()
Removes all logging handlers from the root logger. By default, all BEAM log messages are echoed to the console. Call this method if you don't want this behaviour.


ensureLogPathFromPatternExists

public static void ensureLogPathFromPatternExists(String logPattern)

createLogHeader

public static String createLogHeader(String appName,
                                     String appVersion,
                                     String copyrightInfo)


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.