org.jlf.log
Class LogProperties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--org.jlf.log.LogProperties
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class LogProperties
extends java.util.Properties

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 main application property file retrieved from the AppInfo class. The following property tags and defaults will be used when reading the log property file:

 LogFileExtension = log
 LogFilePath = c:\\temp\\
 LoggingLevel = 4
 LoggingMechanism = org.jlf.log.StandardErrLoggingMechanism
 LogFieldSeparator = |
 
Any of the above property tags can be overridden for a particular log, by prefixing the property key by the log name. 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
 org.jlf.log.AppLog.LoggingLevel = 3
 org.jlf.log.AppLog.LoggingMechanism2 = org.jlf.log.fileMechanisms.UniqueDatedFileLoggingMechanism
 org.jlf.log.AppLog.LoggingMechanism3 = org.jlf.log.smtpMechanism.SMTPLoggingMechanism
 org.jlf.log.AppLog.LogFieldSeparator = >
 
For the SMTP (mail) logging mechanism, there are global settings for the mail transport as follows:
 SMTPHost=mail
 SMTPUser=
 SMTPUserPassword=
 
For the SMTP (mail) logging mechanism, there are local log settings to tell what criticality of messages go to which mailboxes (the default is that no messages go anywhere!):
 SMTPSendToAddresses.1=level1Support@catapult-technologies.com
 SMTPMaximumMessageLength=20000
 SMTPMessageIntervalInMinutes=5
 SMTPMaximumEntriesInMessage=50
 org.jlf.log.SQLLog.SMTPSendToAddresses.1=databaseSupport@catapult-technologies.com,level1Support@catapult-technologies.com
 org.jlf.log.SQLLog.SMTPSendToAddresses.2=databaseSupport@catapult-technologies.com
 
The above entries would send all level 1 errors for any log with an active SMTPLoggingMechanism to level1Support email box. The SQLLog log would override to send level 1 and 2 errors to the databaseSupport mail box. Messages are sent once every 5 minutes only, with a maximum message length of 20000 characters only and maximum number of log entries in a message 50 (oldest log entries discarded first).

See Also:
AppInfo, Serialized Form

Field Summary
protected static java.lang.String DEFAULT_ENTRY_MAX
           
static java.lang.String DEFAULT_LOG_FIELD_SEPARATOR
           
static java.lang.String DEFAULT_LOG_FILE_EXTENSION
           
static java.lang.String DEFAULT_LOG_FILE_PATH
           
static int DEFAULT_LOGGING_LEVEL
           
static java.lang.String DEFAULT_LOGGING_MECHANISM
           
protected static java.lang.String DEFAULT_MESSAGE_INTERVAL_MINUTES
           
protected static java.lang.String DEFAULT_SMTP_ADDRESS
           
protected static java.lang.String DEFAULT_SMTP_MAX_LENGTH
           
protected static boolean initialized
           
protected static java.lang.String LOG_FIELD_SEPARATOR_PROPERTY
           
protected static java.lang.String LOG_FILE_EXTENSION_PROPERTY
           
protected static java.lang.String LOG_FILE_PATH_PROPERTY
           
protected static java.lang.String LOGGING_LEVEL_PROPERTY
           
protected static java.lang.String LOGGING_MECHANISM_PROPERTY
           
protected static java.lang.String PROPERTY_FILE_EXTENSION
           
protected static LogProperties singleton
           
protected static java.lang.String SMTP_ADDRESSES_PROPERTY
           
protected static java.lang.String SMTP_ENTRY_MAX_PROPERTY
           
protected static java.lang.String SMTP_MAX_LENGTH_PROPERTY
           
protected static java.lang.String SMTP_MESSAGE_INTERVAL_MINUTES_PROPERTY
           
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
LogProperties()
           
 
Method Summary
 boolean containsLogProperty(Log log, java.lang.String key)
          Checks the property file to see if a property is in the file.
static LogProperties getInstance()
          Class accessor (Factory Method) which answers the Singleton instance of the LogProperties for this virtual machine.
 java.lang.String getLogFieldSeparator(Log log)
          Return the logging level for the log given.
 java.lang.String getLoggingExtension(Log log)
          Return the file name extension the log file should be written out under.
 int getLoggingLevel(Log log)
          Return the logging level for the log given.
 java.lang.String getLoggingLevelProperty(Log log, int loggingLevel, java.lang.String propertyKey, java.lang.String defaultValue)
          Returns an property specific to a logging level, which can be overridden by a specific log.
 java.util.Vector getLoggingMechanismNames(Log log)
          Return the logging mechanisms for the log given.
 java.lang.String getLoggingPath(Log log)
          Return the file path the log file should be written out under.
 java.lang.String getLogProperty(Log log, java.lang.String key, java.lang.String defaultValue)
          Returns the default property for the key given by first looking for a property prefixed by the log name.
 long getLongLoggingLevelProperty(Log log, int loggingLevel, java.lang.String propertyKey, java.lang.String defaultValue)
          Returns an property specific to a logging level, which can be overridden by a specific log.
 java.lang.String getSMTPAddresses(Log log, int loggingLevel)
          Returns email address(es) for the log and logging level given as input.
 long getSMTPMaximumMessageLength(Log log, int loggingLevel)
          Returns an email address for the log and logging level given as input.
 long getSMTPMaxLogEntriesInAMessage(Log log, int loggingLevel)
          Returns the maximum amount of log entries allowed in a particular message.
 long getSMTPMessageSendIntervalInMinutes(Log log, int loggingLevel)
          Returns an email address for the log and logging level given as input.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_FILE_EXTENSION

protected static final java.lang.String PROPERTY_FILE_EXTENSION
See Also:
Constant Field Values

LOG_FILE_PATH_PROPERTY

protected static final java.lang.String LOG_FILE_PATH_PROPERTY
See Also:
Constant Field Values

DEFAULT_LOG_FILE_PATH

public static final java.lang.String DEFAULT_LOG_FILE_PATH
See Also:
Constant Field Values

LOG_FILE_EXTENSION_PROPERTY

protected static final java.lang.String LOG_FILE_EXTENSION_PROPERTY
See Also:
Constant Field Values

DEFAULT_LOG_FILE_EXTENSION

public static final java.lang.String DEFAULT_LOG_FILE_EXTENSION
See Also:
Constant Field Values

LOGGING_MECHANISM_PROPERTY

protected static final java.lang.String LOGGING_MECHANISM_PROPERTY
See Also:
Constant Field Values

DEFAULT_LOGGING_MECHANISM

public static final java.lang.String DEFAULT_LOGGING_MECHANISM
See Also:
Constant Field Values

LOGGING_LEVEL_PROPERTY

protected static final java.lang.String LOGGING_LEVEL_PROPERTY
See Also:
Constant Field Values

DEFAULT_LOGGING_LEVEL

public static final int DEFAULT_LOGGING_LEVEL
See Also:
Constant Field Values

LOG_FIELD_SEPARATOR_PROPERTY

protected static final java.lang.String LOG_FIELD_SEPARATOR_PROPERTY
See Also:
Constant Field Values

DEFAULT_LOG_FIELD_SEPARATOR

public static final java.lang.String DEFAULT_LOG_FIELD_SEPARATOR
See Also:
Constant Field Values

initialized

protected static boolean initialized

singleton

protected static LogProperties singleton

SMTP_ADDRESSES_PROPERTY

protected static final java.lang.String SMTP_ADDRESSES_PROPERTY
See Also:
Constant Field Values

DEFAULT_SMTP_ADDRESS

protected static final java.lang.String DEFAULT_SMTP_ADDRESS
See Also:
Constant Field Values

SMTP_MAX_LENGTH_PROPERTY

protected static final java.lang.String SMTP_MAX_LENGTH_PROPERTY
See Also:
Constant Field Values

DEFAULT_SMTP_MAX_LENGTH

protected static final java.lang.String DEFAULT_SMTP_MAX_LENGTH
See Also:
Constant Field Values

SMTP_MESSAGE_INTERVAL_MINUTES_PROPERTY

protected static final java.lang.String SMTP_MESSAGE_INTERVAL_MINUTES_PROPERTY
See Also:
Constant Field Values

DEFAULT_MESSAGE_INTERVAL_MINUTES

protected static final java.lang.String DEFAULT_MESSAGE_INTERVAL_MINUTES
See Also:
Constant Field Values

SMTP_ENTRY_MAX_PROPERTY

protected static final java.lang.String SMTP_ENTRY_MAX_PROPERTY
See Also:
Constant Field Values

DEFAULT_ENTRY_MAX

protected static final java.lang.String DEFAULT_ENTRY_MAX
See Also:
Constant Field Values
Constructor Detail

LogProperties

public LogProperties()
Method Detail

getInstance

public static LogProperties getInstance()
Class accessor (Factory Method) which answers the Singleton instance of the LogProperties for this virtual machine.


containsLogProperty

public boolean containsLogProperty(Log log,
                                   java.lang.String key)
Checks the property file to see if a property is in the file. A property can either be defined as a property global to all logs or specific to the log given.


getLogProperty

public java.lang.String getLogProperty(Log log,
                                       java.lang.String key,
                                       java.lang.String defaultValue)
Returns the default property for the key given by first looking for a property prefixed by the log name. If none found, then try a generic property for all logs, and if none found there, return the defaultValue given.


getLoggingPath

public java.lang.String getLoggingPath(Log log)
Return the file path the log file should be written out under.


getLoggingExtension

public java.lang.String getLoggingExtension(Log log)
Return the file name extension the log file should be written out under.


getLoggingMechanismNames

public java.util.Vector getLoggingMechanismNames(Log log)
Return the logging mechanisms for the log given.


getLoggingLevel

public int getLoggingLevel(Log log)
Return the logging level for the log given.


getLogFieldSeparator

public java.lang.String getLogFieldSeparator(Log log)
Return the logging level for the log given.


getLoggingLevelProperty

public java.lang.String getLoggingLevelProperty(Log log,
                                                int loggingLevel,
                                                java.lang.String propertyKey,
                                                java.lang.String defaultValue)
Returns an property specific to a logging level, which can be overridden by a specific log.


getLongLoggingLevelProperty

public long getLongLoggingLevelProperty(Log log,
                                        int loggingLevel,
                                        java.lang.String propertyKey,
                                        java.lang.String defaultValue)
Returns an property specific to a logging level, which can be overridden by a specific log.


getSMTPAddresses

public java.lang.String getSMTPAddresses(Log log,
                                         int loggingLevel)
Returns email address(es) for the log and logging level given as input. If none found, return empty string.


getSMTPMaximumMessageLength

public long getSMTPMaximumMessageLength(Log log,
                                        int loggingLevel)
Returns an email address for the log and logging level given as input. If none found, return empty string.


getSMTPMessageSendIntervalInMinutes

public long getSMTPMessageSendIntervalInMinutes(Log log,
                                                int loggingLevel)
Returns an email address for the log and logging level given as input. If none found, return empty string.


getSMTPMaxLogEntriesInAMessage

public long getSMTPMaxLogEntriesInAMessage(Log log,
                                           int loggingLevel)
Returns the maximum amount of log entries allowed in a particular message. The oldest entries are thrown away.