Logging Service

Turbine's logging service is exceptionally powerful. The reason why it is so powerful is because it provides an API which is extensible in that any logging system can be configured to run under the covers. Turbine provides by default implementations for 4 different logging systems: Log4J, Avalon's LogKit, The Servlet API's logging system and a simple file logging system. The facility.className is what decides which logger system to use.

Configuration

# -------------------------------------------------------------------
# 
#  S E R V I C E S
#
# -------------------------------------------------------------------
# Classes for Turbine Services should be defined here.
# Format: services.[name].classname=[implementing class]
#
# To specify properties of a service use the following syntax:
# service.[name].[property]=[value]

services.LoggingService.classname=org.apache.turbine.services.logging.TurbineLoggingService
.
.
.
# -------------------------------------------------------------------
# 
#  L O G S
#
# -------------------------------------------------------------------
# This is the configuration for the logging system. In most cases
# you don't need to modify anything. However, if you wish to add more
# facilities or modify the existing settings, then you can do so.
#
# destination.file: A path relative to the web app root
# -------------------------------------------------------------------
services.LoggingService.facilities=system,debug
services.LoggingService.default=system
services.LoggingService.loggingConfig=org.apache.turbine.services.logging.PropertiesLoggingConfig

# A facility for system logging.
services.LoggingService.system.destination.file=/path/to/file.log
services.LoggingService.system.className=org.apache.turbine.services.logging.FileLogger
services.LoggingService.system.level=INFO

# A facility for the scheduler service
# To disable started/stopped messages set the level to ERROR
services.LoggingService.scheduler.destination.file=/path/to/file.log
services.LoggingService.scheduler.className=org.apache.turbine.services.logging.FileLogger
services.LoggingService.scheduler.level=INFO

Usage

To use the Logging system, all you need to do is configure a facility in the TR.props file, what facilities to use for logging and then reference a facility in your code. It is also possible to configure a "default" logging facility where all log messages go when a facility is not specified.

import org.apache.turbine.util.Log;

Log.info("system", "this is a message that would go to the system facility");