public abstract class Logger
extends java.lang.Object
You can use the selectLoggerLibrary(int)
static method to force
use of a specific logger package, or to turn off logging.
SLF4J or Apache Commons Logging are supported (since FreeMarker 2.3.17)
and recommended, but are never selected automatically (until FreeMarker 2.4)
due to backward compatibility constraints; you have to select them
explicitly with selectLoggerLibrary(int)
.
Modifier and Type | Field and Description |
---|---|
static int |
LIBRARY_AUTO
Constant used with
selectLoggerLibrary(int) that indicates the
engine should automatically lookup and use any available logger library. |
static int |
LIBRARY_AVALON
Constant used with
selectLoggerLibrary(int) that indicates the
engine should use the Apache Jakarta Avalon LogKit logger package. |
static int |
LIBRARY_COMMONS
Constant used with
selectLoggerLibrary(int) that indicates the
engine should use the Apache commons-logging logger adapter package. |
static int |
LIBRARY_JAVA
Constant used with
selectLoggerLibrary(int) that indicates the
engine should use the java.util.logging logger package. |
static int |
LIBRARY_LOG4J
Constant used with
selectLoggerLibrary(int) that indicates the
engine should use the Apache Jakarta Log4J logger package. |
static int |
LIBRARY_NONE
Constant used with
selectLoggerLibrary(int) that indicates the
engine should use no logger package (i.e. turn off logging). |
static int |
LIBRARY_SLF4J
Constant used with
selectLoggerLibrary(int) that indicates the
engine should use the SLF4J logger adapter package. |
Constructor and Description |
---|
Logger() |
Modifier and Type | Method and Description |
---|---|
abstract void |
debug(java.lang.String message)
Logs a debugging message.
|
abstract void |
debug(java.lang.String message,
java.lang.Throwable t)
Logs a debugging message with accompanying throwable.
|
abstract void |
error(java.lang.String message)
Logs an error message.
|
abstract void |
error(java.lang.String message,
java.lang.Throwable t)
Logs an error message with accompanying throwable.
|
static Logger |
getLogger(java.lang.String category)
Returns a logger for the specified category.
|
abstract void |
info(java.lang.String message)
Logs an informational message.
|
abstract void |
info(java.lang.String message,
java.lang.Throwable t)
Logs an informational message with accompanying throwable.
|
abstract boolean |
isDebugEnabled()
Returns true if this logger will log debug messages.
|
abstract boolean |
isErrorEnabled()
Returns true if this logger will log error messages.
|
abstract boolean |
isFatalEnabled()
Returns true if this logger will log fatal error messages.
|
abstract boolean |
isInfoEnabled()
Returns true if this logger will log informational messages.
|
abstract boolean |
isWarnEnabled()
Returns true if this logger will log warning messages.
|
static void |
selectLoggerLibrary(int library)
Selects the logger library to use.
|
static void |
setCategoryPrefix(java.lang.String prefix)
Sets a category prefix.
|
abstract void |
warn(java.lang.String message)
Logs a warning message.
|
abstract void |
warn(java.lang.String message,
java.lang.Throwable t)
Logs a warning message with accompanying throwable.
|
public static final int LIBRARY_AUTO
selectLoggerLibrary(int)
that indicates the
engine should automatically lookup and use any available logger library.public static final int LIBRARY_NONE
selectLoggerLibrary(int)
that indicates the
engine should use no logger package (i.e. turn off logging).public static final int LIBRARY_JAVA
selectLoggerLibrary(int)
that indicates the
engine should use the java.util.logging logger package.public static final int LIBRARY_AVALON
selectLoggerLibrary(int)
that indicates the
engine should use the Apache Jakarta Avalon LogKit logger package.public static final int LIBRARY_LOG4J
selectLoggerLibrary(int)
that indicates the
engine should use the Apache Jakarta Log4J logger package.public static final int LIBRARY_COMMONS
selectLoggerLibrary(int)
that indicates the
engine should use the Apache commons-logging logger adapter package.public static final int LIBRARY_SLF4J
selectLoggerLibrary(int)
that indicates the
engine should use the SLF4J logger adapter package.public static void selectLoggerLibrary(int library) throws java.lang.ClassNotFoundException
library
- one of LIBRARY_XXX constants. By default,
LIBRARY_AUTO
is used.java.lang.ClassNotFoundException
- if an explicit logging library is asked for
(that is, neither NONE, nor AUTO), and it's not found in the classpath.public static void setCategoryPrefix(java.lang.String prefix)
public abstract void debug(java.lang.String message)
public abstract void debug(java.lang.String message, java.lang.Throwable t)
public abstract void info(java.lang.String message)
public abstract void info(java.lang.String message, java.lang.Throwable t)
public abstract void warn(java.lang.String message)
public abstract void warn(java.lang.String message, java.lang.Throwable t)
public abstract void error(java.lang.String message)
public abstract void error(java.lang.String message, java.lang.Throwable t)
public abstract boolean isDebugEnabled()
public abstract boolean isInfoEnabled()
public abstract boolean isWarnEnabled()
public abstract boolean isErrorEnabled()
public abstract boolean isFatalEnabled()
public static Logger getLogger(java.lang.String category)
category
- a dot separated hierarchical category name. If a category
prefix is in effect, it's prepended to the category name.