freemarker.log

Class Logger


public abstract class Logger
extends java.lang.Object

The FreeMarker logging facility. This is a polymorphic implementation that will use whatever logging package it can find on the system: Apache Jakarta Log4J, Apache Jakarta Avalon LogKit, JDK1.4 logging (in this order). If it fails to find any of the above, logging will be suppressed and a short notice output to System.err. You can use the selectLoggerLibrary(int) static method to force use of a specific logger package, or to turn off logging.
Version:
$Id: Logger.java,v 1.24 2003/10/03 15:35:10 stephanmueller Exp $
Author:
Attila Szegedi

Field Summary

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_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.

Method Summary

abstract void
debug(String message)
Logs a debugging message.
abstract void
debug(String message, Throwable t)
Logs a debugging message with accompanying throwable.
abstract void
error(String message)
Logs an error message.
abstract void
error(String message, Throwable t)
Logs an error message with accompanying throwable.
static Logger
getLogger(String category)
Returns a logger for the specified category.
abstract void
info(String message)
Logs an informational message.
abstract void
info(String message, 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(String prefix)
Sets a category prefix.
abstract void
warn(String message)
Logs a warning message.
abstract void
warn(String message, Throwable t)
Logs a warning message with accompanying throwable.

Field Details

LIBRARY_AUTO

public static final int LIBRARY_AUTO
Constant used with selectLoggerLibrary(int) that indicates the engine should automatically lookup and use any available logger library.
Field Value:
-1

LIBRARY_AVALON

public static final int LIBRARY_AVALON
Constant used with selectLoggerLibrary(int) that indicates the engine should use the Apache Jakarta Avalon LogKit logger package.
Field Value:
2

LIBRARY_JAVA

public static final int LIBRARY_JAVA
Constant used with selectLoggerLibrary(int) that indicates the engine should use the java.util.logging logger package.
Field Value:
1

LIBRARY_LOG4J

public static final int LIBRARY_LOG4J
Constant used with selectLoggerLibrary(int) that indicates the engine should use the Apache Jakarta Log4J logger package.
Field Value:
3

LIBRARY_NONE

public static final int LIBRARY_NONE
Constant used with selectLoggerLibrary(int) that indicates the engine should use no logger package (i.e. turn off logging).
Field Value:
0

Method Details

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.

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.

getLogger

public static Logger getLogger(String category)
Returns a logger for the specified category.
Parameters:
category - a dot separated hierarchical category name. If a category prefix is in effect, it is prepended to the category name.

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.

isDebugEnabled

public abstract boolean isDebugEnabled()
Returns true if this logger will log debug 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.

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.

selectLoggerLibrary

public static void selectLoggerLibrary(int library)
            throws ClassNotFoundException
Selects 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.

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.

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.