org.openmdx.kernel.log.impl
Class LogProperties

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

public class LogProperties
extends Object

LogProperties is a concrete class which manages all of the default start-up properties for logs. There is only one singleton instance of this class. The first time the application uses this class, it will attempt to read its properties from the file named [App].log.properties in the current directory, where [App] is the application name taken from the associated log class. If the file cannot be read the default property file LogProperties.properties from the log package will be read instead. This allows an easy "out-of-the-box" usage of the log package as well as sophisticated configuration capabilites. The following property tags and defaults will be used when reading the log property file:

 ApplicationId = XXXX
 LogFileExtension = log
 LogFilePath = c:/temp
 LogLevel = 2
 java.LoggingMechanism = StandardErrLoggingMechanism
 LogPerformance = {false|true}
 LogStatistics = {false|true}
 LogNotification = {false|true}
 ApplicationControlledTracing = {false|true}
 LogVmPropertiesSuppress = item1,item2,item3,...
 

If the property 'LogFilePath' is empty the file logs go to the current working directory. If the property 'LogFilePath' is omitted the file logs go to the platforms temp directory (Usually /tmp for UNIX, and "C:\Documents and Settings\%USER%\Local Settings\Temp" on Windows 2000 (according to the environment variable TEMP).

Any of the above property tags (except 'LogFileExtension' and 'LogFilePath' can be overridden for a particular log, by prefixing the property key by the log name.

If 'LogVmPropertiesSuppress' is missing only some standard VM properties get logged. If 'LogVmPropertiesSuppress' contains a comma separated list of suppressed property names all VM properties except the ones that match the suppress list are logged. A property matches the suppress list if it its name contains one of the suppressed items.

Also note that because you may have more than one logging mechanism open for the same log, append a consecutive integer to the property starting at 2.

For example:

 LogFilePath = /tmp
 AppLog.LogLevel = 3
 AppLog.java.LoggingMechanism  = StandardErrorLoggingMechanism
 AppLog.java.LoggingMechanism2 = SharedFileLoggingMechanism
 AppLog.java.LoggingMechanism3 = CorbaLoggingMechanism
 


Field Summary
static String STANDARD_ERROR_MECHANISM
           
 
Constructor Summary
LogProperties(Log log, String configName, ClassLoader propertyFileClassLoader, Properties applicationProperties)
          Constructor
 
Method Summary
 Properties getAllProperties()
          Returns all properties.
 String getApplicationId(String logName)
          Returns application.
 String getLoggingExtension(String logName)
          Returns the log filename extension for a specific logger.
 int getLoggingLevel(String logName)
          Returns the logging level for a specific logger.
 String[] getLoggingMechanismNames(String logName)
          Return the logging mechanisms for a specific logger.
 String getLoggingPath(String logName)
          Returns the file path the log file should be written out under.
 String getProperty(String logName, String key, String defaultValue)
          Returns the log property for a given key.
static boolean isDebuggingEnabled()
          Checks if log framework debugging is enabled.
 boolean isLoggingNotification(String logName)
          Checks if log notification is enabled for a specific logger
 boolean isLoggingPerformance(String logName)
          Checks if performance logs are enabled for a specific logger.
 boolean isLoggingStatistics(String logName)
          Checks if statistics logs are enabled for a specific logger.
 String toString()
          Returns a string representation of log properties read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STANDARD_ERROR_MECHANISM

public static final String STANDARD_ERROR_MECHANISM
See Also:
Constant Field Values
Constructor Detail

LogProperties

public LogProperties(Log log,
                     String configName,
                     ClassLoader propertyFileClassLoader,
                     Properties applicationProperties)
Constructor

Method Detail

getAllProperties

public Properties getAllProperties()
Returns all properties.

Returns:
the properties

getProperty

public String getProperty(String logName,
                          String key,
                          String defaultValue)
Returns the log property for a given key.

Actually tries to read properties using the following name strategy and returns the default value if no value could be found for any of the names.

Parameters:
logName - a logger's name {AppLog, SysLog, ...}
key - the propertie's name
defaultValue - the propertie's default value
Returns:
the propertie's value

getApplicationId

public String getApplicationId(String logName)
Returns application. The default application id is the configuration name.

Parameters:
logName - a logger's name {AppLog, SysLog, ...}
Returns:
an application id

getLoggingPath

public String getLoggingPath(String logName)
Returns the file path the log file should be written out under.

Parameters:
logName - a logger's name {AppLog, SysLog, ...}
Returns:
a file path

getLoggingExtension

public String getLoggingExtension(String logName)
Returns the log filename extension for a specific logger.

Parameters:
logName - a logger's name {AppLog, SysLog, ...}
Returns:
a filename extension (e.g.: ".log")

getLoggingMechanismNames

public String[] getLoggingMechanismNames(String logName)
Return the logging mechanisms for a specific logger.

Parameters:
logName - a logger's name {AppLog, SysLog, ...}
Returns:
an array of mechanism names

getLoggingLevel

public int getLoggingLevel(String logName)
Returns the logging level for a specific logger. The default level is "warning".

Parameters:
logName - a logger's name {AppLog, SysLog, ...}
Returns:
a log level (according to class LogLevel)

isLoggingPerformance

public boolean isLoggingPerformance(String logName)
Checks if performance logs are enabled for a specific logger.

Parameters:
logName - a logger's name {AppLog, SysLog, ...}
Returns:
true if performance logs are enabled

isLoggingStatistics

public boolean isLoggingStatistics(String logName)
Checks if statistics logs are enabled for a specific logger.

Parameters:
logName - a logger's name {AppLog, SysLog, ...}
Returns:
true if statistics logs are enabled

isLoggingNotification

public boolean isLoggingNotification(String logName)
Checks if log notification is enabled for a specific logger

Parameters:
logName - a logger's name {AppLog, SysLog, ...}
Returns:
true if notification logs are enabled

isDebuggingEnabled

public static boolean isDebuggingEnabled()
Checks if log framework debugging is enabled.

Returns:
true if log framework debugging is enabled

toString

public String toString()
Returns a string representation of log properties read

Overrides:
toString in class Object
Returns:
a String


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