Package freemarker.log
Class Logger
- java.lang.Object
-
- freemarker.log.Logger
-
public abstract class Logger extends Object
The FreeMarker logging facility. This is a polymorphic implementation that will use whatever logging package it can find on the system: SLF4J, Apache Commons Logging, Apache Log4J, Apache Avalon LogKit, java.util.logging (in this order). If it fails to find any of the above, logging will be suppressed and a short notice will be printed to System.err.You can use the
selectLoggerLibrary(int)static method to force use of a specific logger package, or to turn off logging.
-
-
Field Summary
Fields Modifier and Type Field Description static intLIBRARY_AUTOConstant used withselectLoggerLibrary(int)that indicates the engine should automatically lookup and use any available logger library.static intLIBRARY_JAVAConstant used withselectLoggerLibrary(int)that indicates the engine should use the java.util.logging logger package.static intLIBRARY_NONEConstant used withselectLoggerLibrary(int)that indicates the engine should use no logger package (i.e.static intLIBRARY_SLF4JConstant used withselectLoggerLibrary(int)that indicates the engine should use the SLF4J logger adapter package.
-
Constructor Summary
Constructors Constructor Description Logger()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voiddebug(String message)Logs a debugging message.abstract voiddebug(String message, Throwable t)Logs a debugging message with accompanying throwable.abstract voiderror(String message)Logs an error message.abstract voiderror(String message, Throwable t)Logs an error message with accompanying throwable.static LoggergetLogger(String category)Returns a logger for the specified category.abstract voidinfo(String message)Logs an informational message.abstract voidinfo(String message, Throwable t)Logs an informational message with accompanying throwable.abstract booleanisDebugEnabled()Returns true if this logger will log debug messages.abstract booleanisErrorEnabled()Returns true if this logger will log error messages.abstract booleanisFatalEnabled()Returns true if this logger will log fatal error messages.abstract booleanisInfoEnabled()Returns true if this logger will log informational messages.abstract booleanisWarnEnabled()Returns true if this logger will log warning messages.static voidselectLoggerLibrary(int library)Selects the logger library to use.static voidsetCategoryPrefix(String prefix)Sets a category prefix.abstract voidwarn(String message)Logs a warning message.abstract voidwarn(String message, Throwable t)Logs a warning message with accompanying throwable.
-
-
-
Field Detail
-
LIBRARY_AUTO
public static final int LIBRARY_AUTO
Constant used withselectLoggerLibrary(int)that indicates the engine should automatically lookup and use any available logger library.- See Also:
- Constant Field Values
-
LIBRARY_NONE
public static final int LIBRARY_NONE
Constant used withselectLoggerLibrary(int)that indicates the engine should use no logger package (i.e. turn off logging).- See Also:
- Constant Field Values
-
LIBRARY_JAVA
public static final int LIBRARY_JAVA
Constant used withselectLoggerLibrary(int)that indicates the engine should use the java.util.logging logger package.- See Also:
- Constant Field Values
-
LIBRARY_SLF4J
public static final int LIBRARY_SLF4J
Constant used withselectLoggerLibrary(int)that indicates the engine should use the SLF4J logger adapter package.- See Also:
- Constant Field Values
-
-
Method Detail
-
selectLoggerLibrary
public static void selectLoggerLibrary(int library) throws ClassNotFoundExceptionSelects the logger library to use. If you want to change the default setting, do it early in application initialization phase, before calling any other FreeMarker API since once various parts of the FreeMarker library bind to the logging subsystem, the change in this value will have no effect on them.- Parameters:
library- one of LIBRARY_XXX constants. By default,LIBRARY_AUTOis used.- Throws:
ClassNotFoundException- if an explicit logging library is asked for (that is, neither NONE, nor AUTO), and it is not found in the classpath.
-
setCategoryPrefix
public static void setCategoryPrefix(String prefix)
Sets a category prefix. This prefix is prepended to any logger category name. This makes it possible to have different FreeMarker logger categories on a per-application basis (better said, per-classloader basis). By default the category prefix is the empty string. If you set a non-empty category prefix, be sure to include the trailing separator dot (i.e. "MyApp.") If you want to change the default setting, do it early in application initialization phase, before calling any other FreeMarker API since once various parts of the FreeMarker library bind to the logging subsystem, the change in this value will have no effect on them.
-
debug
public abstract void debug(String message)
Logs a debugging message.
-
debug
public abstract void debug(String message, Throwable t)
Logs a debugging message with accompanying throwable.
-
info
public abstract void info(String message)
Logs an informational message.
-
info
public abstract void info(String message, Throwable t)
Logs an informational message with accompanying throwable.
-
warn
public abstract void warn(String message)
Logs a warning message.
-
warn
public abstract void warn(String message, Throwable t)
Logs a warning message with accompanying throwable.
-
error
public abstract void error(String message)
Logs an error message.
-
error
public abstract void error(String message, Throwable t)
Logs an error message with accompanying throwable.
-
isDebugEnabled
public abstract boolean isDebugEnabled()
Returns true if this logger will log debug messages.
-
isInfoEnabled
public abstract boolean isInfoEnabled()
Returns true if this logger will log informational messages.
-
isWarnEnabled
public abstract boolean isWarnEnabled()
Returns true if this logger will log warning messages.
-
isErrorEnabled
public abstract boolean isErrorEnabled()
Returns true if this logger will log error messages.
-
isFatalEnabled
public abstract boolean isFatalEnabled()
Returns true if this logger will log fatal error messages.
-
-