|
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.FileLogger
Implementation of the Apache Commons
org.apache.commons.logging.Log interface which represents a
logger for logging messages to a local log file.
A Common Base Event start event is logged whenever this logger begins logging to the local log file. Conversely, a Common Base Event stop event is logged whenever this logger finishes logging to the local log file.
The logging level is used to filter which severity of logged messages are sent to the local log file. 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
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.FileLogger...
- or -
System.setProperty("org.apache.commons.logging.Log","org.eclipse.hyades.logging.commons.FileLogger");
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.FileLogger");
An instance of this class may be configured to log to a local log file (e.g. absolute or relative path to the local log file) using one of the following methods:
1) Look for a system property named
org.eclipse.hyades.logging.commons.FileLogger.FileName at
logger creation. For example,
...-Dorg.eclipse.hyades.logging.commons.FileLogger.FileName=/tmp/myLogFile.log...
NOTE: The absolute or relative path to the local log file must be enclosed in
double quotes (e.g. "") if contains one or more spaces.
- or -
System.setProperty("org.eclipse.hyades.logging.commons.FileLogger.FileName","/tmp/myLogFile.log");
2) Programmatically set the absolute or relative path to the local log file.
For example,
logger.setFileName("/tmp/myLogFile.log");
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.FileLogger.LoggerLevel at
logger creation. For example,
...-Dorg.eclipse.hyades.logging.commons.FileLogger.Level=DEBUG...
- or -
System.setProperty("org.eclipse.hyades.logging.commons.FileLogger.Level","DEBUG");
2) Programmatically set the logging level. For example,
logger.setLevelAsString("DEBUG");
- or -
logger.setLevel(FileLogger.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.FileLogger");
System.setProperty("org.eclipse.hyades.logging.commons.FileLogger.Level", "DEBUG");
System.setProperty("org.eclipse.hyades.logging.commons.FileLogger.FileName", "/tmp/myLogFile.log");
Alternatively, users may use the proxy factory specific for org.eclipse.hyades.logging.commons.FileLogger
instances (see org.eclipse.hyades.logging.commons.FileLoggerFactory).
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 file 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:
FileLogger 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,
FileLoggerFactory| 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. |
static int |
TRACE_LEVEL
Trace logging level value. |
static int |
WARN_LEVEL
Warning logging level value. |
| Constructor Summary | |
|---|---|
FileLogger(java.lang.String name)
Constructor to create a logger instance with the parameter name. |
|
| Method Summary | |
|---|---|
void |
debug(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
local log file 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 local log file if
DEBUG logging is currently enabled.
|
void |
error(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
local log file 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 local log file if
ERROR logging is currently enabled.
|
void |
fatal(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
local log file 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 local log file if
FATAL logging is currently enabled.
|
void |
finalize()
Closes the file handle to the local log file. |
java.lang.String |
getFileName()
Returns the absolute or relative path to the local log file. |
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
local log file 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 local log file 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 logger is logging to a local log file. |
boolean |
isTraceEnabled()
Checks if TRACE logging is currently enabled. |
boolean |
isWarnEnabled()
Checks if WARN logging is currently enabled. |
void |
setFileName(java.lang.String fileName)
Sets the absolute or relative path to the local log file. |
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
local log file 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 local log file if
TRACE logging is currently enabled.
|
void |
warn(java.lang.Object record)
Logs the parameter java.lang.Object log record to the
local log file 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 local log file 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
| Constructor Detail |
public FileLogger(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
local log file if TRACE logging is currently enabled.
The log record is first converted to XML and then written to the local
log file.
trace in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.
public void trace(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the local log file if
TRACE logging is currently enabled.
The log record and exception are first converted to XML and then written
to the local log file.
trace in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.throwable - The exception to be logged to the local log file.public void debug(java.lang.Object record)
java.lang.Object log record to the
local log file if DEBUG logging is currently enabled.
The log record is first converted to XML and then written to the local
log file.
debug in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.
public void debug(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the local log file if
DEBUG logging is currently enabled.
The log record and exception are first converted to XML and then written
to the local log file.
debug in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.throwable - The exception to be logged to the local log file.public void info(java.lang.Object record)
java.lang.Object log record to the
local log file if INFO logging is currently enabled.
The log record is first converted to XML and then written to the local
log file.
info in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.
public void info(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the local log file if
INFO logging is currently enabled.
The log record and exception are first converted to XML and then written
to the local log file.
info in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.throwable - The exception to be logged to the local log file.public void warn(java.lang.Object record)
java.lang.Object log record to the
local log file if WARN logging is currently enabled.
The log record is first converted to XML and then written to the local
log file.
warn in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.
public void warn(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the local log file if
WARN logging is currently enabled.
The log record and exception are first converted to XML and then written
to the local log file.
warn in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.throwable - The exception to be logged to the local log file.public void error(java.lang.Object record)
java.lang.Object log record to the
local log file if ERROR logging is currently enabled.
The log record is first converted to XML and then written to the local
log file.
error in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.
public void error(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the local log file if
ERROR logging is currently enabled.
The log record and exception are first converted to XML and then written
to the local log file.
error in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.throwable - The exception to be logged to the local log file.public void fatal(java.lang.Object record)
java.lang.Object log record to the
local log file if FATAL logging is currently enabled.
The log record is first converted to XML and then written to the local
log file.
fatal in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.
public void fatal(java.lang.Object record,
java.lang.Throwable throwable)
java.lang.Object log record and
java.lang.Throwable exception to the local log file if
FATAL logging is currently enabled.
The log record and exception are first converted to XML and then written
to the local log file.
fatal in interface org.apache.commons.logging.Logrecord - The log record to be logged to the local log file.throwable - The exception to be logged to the local log file.public java.lang.String getName()
public void setFileName(java.lang.String fileName)
throws java.lang.IllegalArgumentException
fileName - The absolute or relative path to the local log file.
java.lang.IllegalArgumentException - Attempting to set an illegal absolute or relative path to
the local log file.public java.lang.String getFileName()
public final void finalize()
Object.finalize()public boolean isLogging()
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.
|
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 | ||||||||||