org.openmdx.kernel.log.impl
Class LogPropertiesLoader

java.lang.Object
  extended by org.openmdx.kernel.log.impl.LogPropertiesLoader

public class LogPropertiesLoader
extends Object

A loader for log properties


Field Summary
static String LOG_PROPERTY_FILE_DEFAULT
          The default log property file
static String LOG_PROPERTY_FILE_SUFFIX
          The log property file suffix
static String SYS_LOG_DIR
          A VM System property denoting a directory for the log files
static String SYS_PROPERTY_LOG_DEBUG
          A VM System property to enable/disable the log debugging
static String SYS_PROPERTY_LOG_FILE
          A VM System property denoting a log property file
static String SYS_PROPERTY_LOG_FILE_DIR
          A VM System property denoting a directory for log property files
static String SYS_PROPERTY_SYSLOG_FILE
          A VM System property denoting a log property file
 
Constructor Summary
LogPropertiesLoader(Log log, String configName, ClassLoader classLoader, Properties applicationProperties)
          Loads the log properties following loading priorities.
 
Method Summary
static Properties getLoggingRelatedVmSystemProperties()
          Returns the logging related VM system properties
 String getPropertySource()
          Returns a short description from where the properties have been loaded.
 Properties load()
          Load the properties following the load priority list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYS_LOG_DIR

public static final String SYS_LOG_DIR
A VM System property denoting a directory for the log files

See Also:
Constant Field Values

SYS_PROPERTY_LOG_FILE

public static final String SYS_PROPERTY_LOG_FILE
A VM System property denoting a log property file

See Also:
Constant Field Values

SYS_PROPERTY_SYSLOG_FILE

public static final String SYS_PROPERTY_SYSLOG_FILE
A VM System property denoting a log property file

See Also:
Constant Field Values

SYS_PROPERTY_LOG_FILE_DIR

public static final String SYS_PROPERTY_LOG_FILE_DIR
A VM System property denoting a directory for log property files

See Also:
Constant Field Values

SYS_PROPERTY_LOG_DEBUG

public static final String SYS_PROPERTY_LOG_DEBUG
A VM System property to enable/disable the log debugging

See Also:
Constant Field Values

LOG_PROPERTY_FILE_SUFFIX

public static final String LOG_PROPERTY_FILE_SUFFIX
The log property file suffix

See Also:
Constant Field Values

LOG_PROPERTY_FILE_DEFAULT

public static final String LOG_PROPERTY_FILE_DEFAULT
The default log property file

See Also:
Constant Field Values
Constructor Detail

LogPropertiesLoader

public LogPropertiesLoader(Log log,
                           String configName,
                           ClassLoader classLoader,
                           Properties applicationProperties)
Loads the log properties following loading priorities.

The log property resolving strategy follows this priority list:

 -------------------------------------------------------------------------
 Priority  Resolve
 -------------------------------------------------------------------------
    1      APPLICATION SPECIFIC PROPERTIES
           If application defined properties are available use them.
           An application may set log properties using the static
           method setLogProperties() on the AppLog and SysLog class.
           If no application specific properties are available proceed
           with the next priority level else proceed with priority 6

    2a     VM PROPERTY 
           If the logger is SysLog and the VM property 
           "org.openmdx.log.property.filename.syslog" exist, read the 
           properties from that file. If the file denoted by this property 
           does not exist proceed with the next priority level (2b) else 
           proceed with priority 6

    2b     VM PROPERTY 
           {"org.openmdx.log.property.filename"}
           If this VM system property exists, read the properties from
           that file. If the file denoted by this property does not exist
           proceed with the next priority level  else proceed with 
           priority 6

    3      VM PROPERTY
           {"org.openmdx.log.property.filedir"}
           If this VM system property exists, read the properties from a 
           file "{configname}.log.properties" in the directory denoted by
           this system property. If the log property file does not exist
           in this directory proceed with the next priority level else 
           proceed with priority 6

    4      CURRENT WORKING DIRECTORY
           If a log property file exists in the current working directory,
           read the properties from there otherwise proceed with the
           next priority level else proceed with priority 6
           The file name is "{configname}.log.properties"

    5a     CLASSPATH
           If a log property file "{configname}.log.properties" exists in 
           the classpath read the properties from there otherwise proceed
           with the next priority level else proceed with priority 6
           The property loader uses the classloader that loaded the logger
           class (AppLog, SysLog)

    5b     CLASSPATH
           If a generic log property file "Log.properties" exists in 
           the classpath read the properties from there otherwise proceed
           with the next priority level else proceed with priority 6 
           The property loader uses the classloader that loaded the logger
           class (AppLog, SysLog)

    6      INHERIT SYSLOG 
           If the log properties read so far contain the property
           "InheritSysLog=true" add the SysLog properties. This is
           only available for non SysLog loggers. Proceed with priority 7

    7      DEFAULTS
           As a last resort the default properties are loaded. Any 
           property that has not been loaded so far is set to its default
           value.
 
    8      VM PROPERTY 
           If a log file path VM property "org.openmdx.log.path" exists, 
           it overides any otherwise configured log file path for storing
           the log files.

 
 Remarks:
 
 i)   The {configname} can be set by AppLog.setConfigName() and
      SysLog.setConfigName(). The default is "AppLog" or "SysLog"
      respectively.
 
 ii)  Each logger (AppLog, SysLog, ..) loads its properties following
      this strategy.
 
 

Parameters:
log - A logger
configName - The configuration name
classLoader - A classloader
applicationProperties - Applicationproperties may be a null object
Method Detail

load

public Properties load()
Load the properties following the load priority list.

The default properties get merged with the properties from any other properties obtained for a specific priority level.

Returns:
properties (is never null)

getPropertySource

public String getPropertySource()
Returns a short description from where the properties have been loaded.

Returns:
A property source

getLoggingRelatedVmSystemProperties

public static Properties getLoggingRelatedVmSystemProperties()
Returns the logging related VM system properties

Returns:
the properties


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.