|
TPTP 4.4.0 Platform Project Public API Specification |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.eclipse.hyades.logging.commons.Logger
Implementation of the Apache Commons
org.apache.commons.logging.Log interface which represents a
logger for logging messages to a Logging Agent with the same name as the
logger.
The logging level is used to filter which severity of logged messages are sent to the Logging Agent with the same name as the logger. The logging level may be set to one of the following logging levels:
-TRACE (least serious and most verbose) -DEBUG -INFO -WARN -ERROR -FATAL (most serious and least verbose)
An instance of this class will be returned from the getLog()
and/or getInstance() APIs on the default
org.apache.commons.logging.LogFactory implementation. The
default org.apache.commons.logging.LogFactory implementation
uses the following discovery process to resolve the configured
org.apache.commons.logging.Log implementation:
1) Look for a system property named
org.apache.commons.logging.Log or
org.apache.commons.logging.log. For example,
...-Dorg.apache.commons.logging.Log=org.eclipse.hyades.logging.commons.Logger...
- or -
System.setProperty("org.apache.commons.logging.Log","org.eclipse.hyades.logging.commons.Logger");
2) Look for a configuration attribute of the default
org.apache.commons.logging.LogFactory implementation named
org.apache.commons.logging.Log. For example,
org.apache.commons.logging.LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log","org.eclipse.hyades.logging.commons.Logger");
An instance of this class may be configured with a logging level using one of the following methods (see above for the supported levels):
1) Look for a system property named
org.eclipse.hyades.logging.commons.Logger.LoggerLevel at
logger creation. For example,
...-Dorg.eclipse.hyades.logging.commons.Logger.Level=DEBUG...
- or -
System.setProperty("org.eclipse.hyades.logging.commons.Logger.Level","DEBUG");
2) Programmatically set the logging level. For example,
logger.setLevelAsString("DEBUG");
- or -
logger.setLevel(Logger.DEBUG_LEVEL);
A logger instance is created and returned when the getLog()
and/or getInstance() APIs on the default
org.apache.commons.logging.LogFactory implementation are
called. Once created, the logger is configurable (e.g. logging level). The
logger is generally consulted on its configuration before every message is
logged for performance reasons. For example,
Log logger = LogFactory.getLog("My Logger");
if(logger.isDebugEnabled()){
logger.debug("My first DEBUG log message.");
logger.debug("My second DEBUG log message.");
}
System.setProperty("org.apache.commons.logging.Log", "org.eclipse.hyades.logging.commons.Logger");
System.setProperty("org.eclipse.hyades.logging.commons.Logger.Level", "DEBUG");
Alternatively, users may use the proxy factory specific for org.eclipse.hyades.logging.commons.Logger
instances (see org.eclipse.hyades.logging.commons.LoggerFactory).
Logged java.lang.Object messages are converted to Common Base Event XML based on a
generic serialization algorithm as implemented in org.eclipse.hyades.logging.events.cbe.util.EventHelpers#convertObjectToCommonBaseEvent(Object,int)
before being logged to the Logging Agent.
Callers may provide a Common Base Event XML file template (see org.eclipse.hyades.logging.core/schema/templateEvent.xsd) to configure the newly created Common Base Event before serialization to XML. The template Event XML file is a well-formed XML document conforming to a predefined XML schema (e.g. templateEvent.xsd). The naming convention used for the template Event XML file is:
<logger name>.event.xml
where <logger name> is the name of this logger. For example, the template event XML file
for the myLogger logger factory would be named myLogger.event.xml.
The desired event configuration template XML file must by on the classpath and accessible by this class. The event configuration template XML file is loaded using the following look-up sequence:
Logger class' class loader
is queried for the event configuration template XML file.NOTE: The Apache Commons logging classes must be on the CLASSPATH at runtime to utilize this logging class
Log,
LogFactory,
LoggingAgent,
LoggerFactory| Field Summary | |
|---|---|
static int |
DEBUG_LEVEL
Debug logging level value. |
static int |
ERROR_LEVEL
Error logging level value. |
static int |
FATAL_LEVEL
Fatal logging level value. |
static int |
INFO_LEVEL
Information logging level value. |
protected LoggingAgent |
loggingAgent
The Logging Agent with the same name as the logger to which successfully logged messages are sent. |
static int |
TRACE_LEVEL
Trace logging level value. |
static int |
WARN_LEVEL
Warning logging level value. |
| Constructor Summary | |
|---|---|
Logger(java.lang.String name)
Constructor to create a logger instance with a Logging Agent using the parameter name. |
|
| Method Summary | |
|---|---|
void |
debug(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
Logging Agent with the same name as the logger if DEBUG logging is
currently enabled.
|
void |
debug(java.lang.Object record,
java.lang.Throwable throwable)
Logs the parameter java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if DEBUG logging is currently enabled.
|
void |
error(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
Logging Agent with the same name as the logger if ERROR logging is
currently enabled.
|
void |
error(java.lang.Object record,
java.lang.Throwable throwable)
Logs the parameter java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if ERROR logging is currently enabled.
|
void |
fatal(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
Logging Agent with the same name as the logger if FATAL logging is
currently enabled.
|
void |
fatal(java.lang.Object record,
java.lang.Throwable throwable)
Logs the parameter java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if FATAL logging is currently enabled.
|
void |
finalize()
De-registers this Logging Agent instance from the Agent Controller. |
int |
getLevel()
Retrieves the integer level of this logger. |
java.lang.String |
getLevelAsString()
Retrieves the string level of this logger. |
java.lang.String |
getName()
Retrieves the name of this logger. |
void |
info(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
Logging Agent with the same name as the logger if INFO logging is
currently enabled.
|
void |
info(java.lang.Object record,
java.lang.Throwable throwable)
Logs the parameter java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if INFO logging is currently enabled.
|
boolean |
isDebugEnabled()
Checks if DEBUG logging is currently enabled. |
boolean |
isErrorEnabled()
Checks if ERROR logging is currently enabled. |
boolean |
isFatalEnabled()
Checks if FATAL logging is currently enabled. |
boolean |
isInfoEnabled()
Checks if INFO logging is currently enabled. |
boolean |
isLogging()
Checks if the Logging Agent is logging (e.g. |
boolean |
isTraceEnabled()
Checks if TRACE logging is currently enabled. |
boolean |
isWarnEnabled()
Checks if WARN logging is currently enabled. |
void |
setLevel(int level)
Sets the logging level to one of the integer logging levels (i.e. |
void |
setLevelAsString(java.lang.String stringLevel)
Sets the logging level to one of the string logging levels (i.e. |
void |
trace(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
Logging Agent with the same name as the logger if TRACE logging is
currently enabled.
|
void |
trace(java.lang.Object record,
java.lang.Throwable throwable)
Logs the parameter java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if TRACE logging is currently enabled.
|
boolean |
waitUntilLogging(long maxTime)
Suspends the current thread until the Logging Agent is monitored or the the parameter maximum time (milliseconds) has expired. |
void |
warn(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
Logging Agent with the same name as the logger if WARN logging is
currently enabled.
|
void |
warn(java.lang.Object record,
java.lang.Throwable throwable)
Logs the parameter java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if WARN logging is currently enabled.
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int TRACE_LEVEL
public static final int DEBUG_LEVEL
public static final int INFO_LEVEL
public static final int WARN_LEVEL
public static final int ERROR_LEVEL
public static final int FATAL_LEVEL
protected LoggingAgent loggingAgent
| Constructor Detail |
public Logger(java.lang.String name)
name - The name of the newly created logger.| Method Detail |
public boolean isTraceEnabled()
isTraceEnabled in interface org.apache.commons.logging.Logpublic boolean isDebugEnabled()
isDebugEnabled in interface org.apache.commons.logging.Logpublic boolean isInfoEnabled()
isInfoEnabled in interface org.apache.commons.logging.Logpublic boolean isWarnEnabled()
isWarnEnabled in interface org.apache.commons.logging.Logpublic boolean isErrorEnabled()
isErrorEnabled in interface org.apache.commons.logging.Logpublic boolean isFatalEnabled()
isFatalEnabled in interface org.apache.commons.logging.Logpublic void trace(java.lang.Object record)
java.lang.Object log record to the
Logging Agent with the same name as the logger if TRACE logging is
currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
trace in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.
public void trace(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if TRACE logging is currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
The parameter java.lang.Object log record is first logged
and then the java.lang.Throwable exception is logged to
the Logging Agent.
trace in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.throwable - The exception to be logged to the Logging Agent.public void debug(java.lang.Object record)
java.lang.Object log record to the
Logging Agent with the same name as the logger if DEBUG logging is
currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
debug in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.
public void debug(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if DEBUG logging is currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
The parameter java.lang.Object log record is first logged
and then the java.lang.Throwable exception is logged to
the Logging Agent.
debug in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.throwable - The exception to be logged to the Logging Agent.public void info(java.lang.Object record)
java.lang.Object log record to the
Logging Agent with the same name as the logger if INFO logging is
currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
info in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.
public void info(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if INFO logging is currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
The parameter java.lang.Object log record is first logged
and then the java.lang.Throwable exception is logged to
the Logging Agent.
info in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.throwable - The exception to be logged to the Logging Agent.public void warn(java.lang.Object record)
java.lang.Object log record to the
Logging Agent with the same name as the logger if WARN logging is
currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
warn in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.
public void warn(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if WARN logging is currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
The parameter java.lang.Object log record is first logged
and then the java.lang.Throwable exception is logged to
the Logging Agent.
warn in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.throwable - The exception to be logged to the Logging Agent.public void error(java.lang.Object record)
java.lang.Object log record to the
Logging Agent with the same name as the logger if ERROR logging is
currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
error in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.
public void error(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if ERROR logging is currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
The parameter java.lang.Object log record is first logged
and then the java.lang.Throwable exception is logged to
the Logging Agent.
error in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.throwable - The exception to be logged to the Logging Agent.public void fatal(java.lang.Object record)
java.lang.Object log record to the
Logging Agent with the same name as the logger if FATAL logging is
currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
fatal in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.
public void fatal(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the Logging Agent with
the same name as the logger if FATAL logging is currently enabled.
The log record is first converted to XML and then sent to the Logging
Agent.
The parameter java.lang.Object log record is first logged
and then the java.lang.Throwable exception is logged to
the Logging Agent.
fatal in interface org.apache.commons.logging.Logrecord - The log record to be logged to the Logging Agent.throwable - The exception to be logged to the Logging Agent.public java.lang.String getName()
public int getLevel()
public java.lang.String getLevelAsString()
public void setLevel(int level)
throws java.lang.IllegalArgumentException
level - The new integer logging level (i.e. TRACE_LEVEL -
FATAL_LEVEL).
java.lang.IllegalArgumentException - Attempting to set an illegal integer logging level.
public void setLevelAsString(java.lang.String stringLevel)
throws java.lang.IllegalArgumentException
stringLevel - The new string logging level (i.e. "TRACE" - "FATAL").
java.lang.IllegalArgumentException - Attempting to set an illegal string logging level.public final void finalize()
finalize in interface IPreemptedLoggerObject.finalize()public boolean waitUntilLogging(long maxTime)
waitUntilLogging in interface IPreemptedLoggermaxTime - the maximum amount of time (milliseconds) to suspend the
current thread
public boolean isLogging()
isLogging in interface IPreemptedLogger
|
TPTP 4.4.0 Platform Project Public API Specification |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||