public abstract class Logger
extends java.lang.Object
log4j-over-slf4j
properly installed (means, you have no real Log4j in your class path, and SLF4J has a
backing implementation like logback-classic
), then FreeMarker will use SLF4J directly instead of Log4j (since
FreeMarker 2.3.22).
If the auto detection sequence describet above doesn't give you the result that you want, see
SYSTEM_PROPERTY_NAME_LOGGER_LIBRARY
.
Modifier and Type | Field and Description |
---|---|
static int |
LIBRARY_AUTO
Enum value used for
selectLoggerLibrary(int) ; indicates auto-selection as described in the class
documentation of Logger() . |
static int |
LIBRARY_AVALON
Deprecated.
Avalon LogKit support will be removed sometimes in the future.
|
static int |
LIBRARY_COMMONS
Enum value used for
selectLoggerLibrary(int) ; indicates that Apache commons-logging should be used. |
static int |
LIBRARY_JAVA
Enum value used for
selectLoggerLibrary(int) ; indicates that java.util.logging should be used. |
static int |
LIBRARY_LOG4J
Enum value used for
selectLoggerLibrary(int) ; indicates that Log4J should be used. |
static java.lang.String |
LIBRARY_NAME_AUTO
"org.freemarker.loggerLibrary" property value; indicates auto-selection as described in the class
documentation of
Logger() . |
static java.lang.String |
LIBRARY_NAME_AVALON
Deprecated.
Avalon LogKit support will be removed sometimes in the future.
|
static java.lang.String |
LIBRARY_NAME_COMMONS_LOGGING
"org.freemarker.loggerLibrary" property value; indicates that Apache commons-logging should be
used.
|
static java.lang.String |
LIBRARY_NAME_JUL
"org.freemarker.loggerLibrary" property value; indicates that
java.util.logging should be
used. |
static java.lang.String |
LIBRARY_NAME_LOG4J
"org.freemarker.loggerLibrary" property value; indicates that Log4J should be used.
|
static java.lang.String |
LIBRARY_NAME_NONE
"org.freemarker.loggerLibrary" property value; indicates that no logging should occur.
|
static java.lang.String |
LIBRARY_NAME_SLF4J
"org.freemarker.loggerLibrary" property value; indicates that SLF4J should be used.
|
static int |
LIBRARY_NONE
Enum value used for
selectLoggerLibrary(int) ; indicates that no logging should occur. |
static int |
LIBRARY_SLF4J
Constant used with
selectLoggerLibrary(int) ; indicates that SLF4J should be used. |
static java.lang.String |
SYSTEM_PROPERTY_NAME_LOGGER_LIBRARY
The "org.freemarker.loggerLibrary" system property is used to select a logger library explicitly,
rather than relying on automatic selection.
|
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 libraryEnum)
Deprecated.
This method isn't reliable, unless you can somehow ensure that you access the FreeMarker classes
first; use the "org.freemarker.loggerLibrary" Java system property instead, like
java ... -Dorg.freemarker.loggerLibrary=slf4j . See
SYSTEM_PROPERTY_NAME_LOGGER_LIBRARY for more. |
static void |
setCategoryPrefix(java.lang.String prefix)
Deprecated.
This wasn't reliable, unless you can somehow ensure that you access the FreeMarker classes first. As
it's not known to be useful for users, consider it removed.
|
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 java.lang.String SYSTEM_PROPERTY_NAME_LOGGER_LIBRARY
java ... -Dorg.freemarker.loggerLibrary=SLF4j
. Setting it from Java code isn't reliable, also it can
cause confusion if you override the value set by others with -D
.
If the requested logging library is not available, an error will be printed to the stderr, then logging will be disabled.
The supported values are:
public static final int LIBRARY_AUTO
selectLoggerLibrary(int)
; indicates auto-selection as described in the class
documentation of Logger()
.public static final java.lang.String LIBRARY_NAME_AUTO
Logger()
. @since 2.3.22public static final int LIBRARY_NONE
selectLoggerLibrary(int)
; indicates that no logging should occur.public static final java.lang.String LIBRARY_NAME_NONE
public static final int LIBRARY_JAVA
selectLoggerLibrary(int)
; indicates that java.util.logging
should be used.public static final java.lang.String LIBRARY_NAME_JUL
java.util.logging
should be
used. @since 2.3.22@Deprecated public static final int LIBRARY_AVALON
selectLoggerLibrary(int)
; indicates that Avalon LogKit should be used.@Deprecated public static final java.lang.String LIBRARY_NAME_AVALON
public static final int LIBRARY_LOG4J
selectLoggerLibrary(int)
; indicates that Log4J should be used.public static final java.lang.String LIBRARY_NAME_LOG4J
public static final int LIBRARY_COMMONS
selectLoggerLibrary(int)
; indicates that Apache commons-logging should be used.public static final java.lang.String LIBRARY_NAME_COMMONS_LOGGING
public static final int LIBRARY_SLF4J
selectLoggerLibrary(int)
; indicates that SLF4J should be used.public static final java.lang.String LIBRARY_NAME_SLF4J
@Deprecated public static void selectLoggerLibrary(int libraryEnum) throws java.lang.ClassNotFoundException
java ... -Dorg.freemarker.loggerLibrary=slf4j
. See
SYSTEM_PROPERTY_NAME_LOGGER_LIBRARY
for more.libraryEnum
- One of LIBRARY_... constants. By default, LIBRARY_AUTO
is used.java.lang.ClassNotFoundException
- if an explicit logging library is asked for (that is, not -1 or
0) and it's not found in the classpath.@Deprecated 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.