org.openmdx.kernel.log.impl
Class Log

java.lang.Object
  extended by org.openmdx.kernel.log.impl.Log
All Implemented Interfaces:
MechanismManagerListener, ManageableMechanism
Direct Known Subclasses:
AppLog, RemoteSinkLog, SysLog

public class Log
extends Object
implements ManageableMechanism, MechanismManagerListener

Log is the base class which defines all of the logging constants and implements any general logging responsibilities. It dispatches the actual logging information over to a concrete subclass of AbstractLoggingMechanism to do the work of writing out the log information.


Field Summary
static boolean isMicrosoftVM
          Reflects if the currently used VM is a Microsoft VM (J#)
 
Constructor Summary
protected Log()
          Prevent instantiation of subclasses
protected Log(String name, Class logClass)
          Public constructor to register a new log with a particular name.
 
Method Summary
protected  void finalize()
          Must close the log for the application if the application did not or could not.
 List getActiveEntities()
          Returns a list of all active (in use) log entities that are available by the file logging mechanisms controlled by this logger.
 BootstrapLogger getBootstrapLogger()
          Returns the bootrap logger
 ConfigDelegate getConfig()
          Returns the logger's configuration object
 Date getDateOpened()
          Return the date the log was opened, only valid if the log is currently open.
 String getHostName()
          Return the host
 String getLogClassName()
          LocationAwareLogger requires the log class name
 int getLoggingLevel()
          Gets the logging level of the current log.
 LogProperties getLogProperties()
          Get the log properties.
 MechanismManager getMechanismManager()
          Returns the logger's mechanism manager.
 String getName()
          Return the name of the log, usually passed in by the constructor.
 List getReadableEntities()
          Returns a list of all readable log entities that are available by the file logging mechanisms controlled by this logger.
 LogEntityReader getReader(LogEntity entity)
          Returns an entity reader for given log entity.
 List getRemoveableEntities()
          Returns a list of all removeable log entities that are available by the file logging mechanisms controlled by this logger.
 boolean isBooted()
          Returns true if the logger has booted..
 boolean isLoggingPerformance()
          Gets the logging performance state of the current log.
 boolean isLoggingStatistics()
          Gets the logging statistics state of the current log.
 void loadConfig(String cfgName, Properties logProperties)
          Load the configuration
 void loadMechanisms()
          Load the mechanisms
 void logEvent(LogEvent event, boolean forceLogging)
          Logs a log event to all mechanisms.
 void logString(Object logSource, String logStringSummary, Object logObj, int loggingLevel, int callStackOff)
          Adds a message string to the log if the log's level is currently set at or above the loggingLevel passed in.
 void mechanismAddedEvent(AbstractLoggingMechanism mech)
          Called when a new mechanism has been added.
 void mechanismRemovedEvent(AbstractLoggingMechanism mech)
          Called when a new mechanism has been removed.
static Log newLog(String name, Class logClass)
          Public constructor to register a new log with a particular name.
 void removeEntity(LogEntity entity)
          Remove a log entity.
 void setApplicationControlledTrace(boolean enable, Thread thread)
          Enables/Disables tracing for the specified thread.
 void setLoggingLevel(int level)
          Changes the logging level of the current log.
 void setLoggingPerformance(boolean newState)
          Changes the logging performance state of the current log.
 void setLoggingStatistics(boolean newState)
          Changes the logging statistics state of the current log.
 String toString()
          Returns a string representation of log properties read
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isMicrosoftVM

public static final boolean isMicrosoftVM
Reflects if the currently used VM is a Microsoft VM (J#)

Constructor Detail

Log

protected Log()
Prevent instantiation of subclasses


Log

protected Log(String name,
              Class logClass)
Public constructor to register a new log with a particular name. The name of the log is very important. It is used as a key into the log properties file to find settings for how the log is to be opened.

Parameters:
name - A log name. E.g.: "AppLog" (mandatory)
logClass - A logger class (mandatory)
Method Detail

newLog

public static Log newLog(String name,
                         Class logClass)
Public constructor to register a new log with a particular name. The name of the log is very important. It is used as a key into the log properties file to find settings for how the log is to be opened.

Parameters:
name - A log name. E.g.: "AppLog" (mandatory)
logClass - A logger class (mandatory)

loadConfig

public void loadConfig(String cfgName,
                       Properties logProperties)
Load the configuration

Parameters:
cfgName - A config name (may be )
logProperties - A list of log properties (may be )

loadMechanisms

public void loadMechanisms()
Load the mechanisms


logEvent

public void logEvent(LogEvent event,
                     boolean forceLogging)
Logs a log event to all mechanisms. It's up to the mechanisam to reject specific log event types (standard logs, statistics logs or performance logs).

Parameters:
event - A log event
forceLogging - log an event even if the currently active log level does not permit logging

logString

public void logString(Object logSource,
                      String logStringSummary,
                      Object logObj,
                      int loggingLevel,
                      int callStackOff)
Adds a message string to the log if the log's level is currently set at or above the loggingLevel passed in. Prepends the current thread name before the log entry.

Parameters:
logSource - a log source object
logStringSummary - The log summary info (single line)
logObj - A log object (detail, to be stringified, a null object my be passed)
loggingLevel - The level at which to log the string.
callStackOff - a call stack correction offset. The offset must be a positive number 0, 1, 2, 3

isBooted

public boolean isBooted()
Returns true if the logger has booted..

The logger has booted if it is properly configured and the mechanims have been loaded.

Returns:
true if booted

getLoggingLevel

public int getLoggingLevel()
Gets the logging level of the current log.


isLoggingPerformance

public boolean isLoggingPerformance()
Gets the logging performance state of the current log.


setLoggingPerformance

public void setLoggingPerformance(boolean newState)
Changes the logging performance state of the current log.


isLoggingStatistics

public boolean isLoggingStatistics()
Gets the logging statistics state of the current log.


setLoggingStatistics

public void setLoggingStatistics(boolean newState)
Changes the logging statistics state of the current log.


setLoggingLevel

public void setLoggingLevel(int level)
Changes the logging level of the current log. Use this method to activate, deactivate, or change the logging detail level of an active log.

Parameters:
level - a new log level

getMechanismManager

public MechanismManager getMechanismManager()
Returns the logger's mechanism manager.

Returns:
a mechanism manager

getConfig

public ConfigDelegate getConfig()
Returns the logger's configuration object

Returns:
the configuration object

mechanismAddedEvent

public void mechanismAddedEvent(AbstractLoggingMechanism mech)
Called when a new mechanism has been added.

From MechanismManagerListener interface

Specified by:
mechanismAddedEvent in interface MechanismManagerListener
Parameters:
mech -

mechanismRemovedEvent

public void mechanismRemovedEvent(AbstractLoggingMechanism mech)
Called when a new mechanism has been removed.

From MechanismManagerListener interface

Specified by:
mechanismRemovedEvent in interface MechanismManagerListener
Parameters:
mech -

getActiveEntities

public List getActiveEntities()
Returns a list of all active (in use) log entities that are available by the file logging mechanisms controlled by this logger.

From ManageableMechanism interface

Specified by:
getActiveEntities in interface ManageableMechanism
Returns:
a list of LogEntity objects

getReadableEntities

public List getReadableEntities()
Returns a list of all readable log entities that are available by the file logging mechanisms controlled by this logger.

From ManageableMechanism interface

Specified by:
getReadableEntities in interface ManageableMechanism
Returns:
a list of log entity names

getRemoveableEntities

public List getRemoveableEntities()
Returns a list of all removeable log entities that are available by the file logging mechanisms controlled by this logger.

From ManageableMechanism interface

Specified by:
getRemoveableEntities in interface ManageableMechanism
Returns:
a list of log entitiy names

removeEntity

public void removeEntity(LogEntity entity)
Remove a log entity.

From ManageableMechanism interface

Specified by:
removeEntity in interface ManageableMechanism
Parameters:
String - an entity name

getReader

public LogEntityReader getReader(LogEntity entity)
Returns an entity reader for given log entity.

From ManageableMechanism interface

Specified by:
getReader in interface ManageableMechanism
Parameters:
String - an entity name
Returns:
A log entity reader for the entity

toString

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

Overrides:
toString in class Object
Returns:
a String

setApplicationControlledTrace

public void setApplicationControlledTrace(boolean enable,
                                          Thread thread)
Enables/Disables tracing for the specified thread. If application controlled tracing has been enabled through configuration setApplicationControlledTrace(true, thread) allows applications to force logs at level TRACE_LEVEL regardless the actual configuration state of the TRACE_LEVEL. A setApplicationControlledTrace(false, thread) lets the log level TRACE_LEVEL control the trace output of the specified thread.

Parameters:
enable - enables/disables trace
thread - the thread that is affected

getLogProperties

public LogProperties getLogProperties()
Get the log properties.

Parameters:
properties - - the properties

getBootstrapLogger

public BootstrapLogger getBootstrapLogger()
Returns the bootrap logger

Parameters:
properties - - the properties

getName

public String getName()
Return the name of the log, usually passed in by the constructor.

Returns:
The logger's name

getDateOpened

public Date getDateOpened()
Return the date the log was opened, only valid if the log is currently open.

Returns:
The logger's open date

getHostName

public String getHostName()
Return the host

Returns:
The hostname

finalize

protected void finalize()
                 throws Throwable
Must close the log for the application if the application did not or could not.

Overrides:
finalize in class Object
Throws:
Throwable - Default finalizer exception

getLogClassName

public final String getLogClassName()
LocationAwareLogger requires the log class name

Returns:
the log class name


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