net.sf.click.extras.service
Class Log4JLogService

java.lang.Object
  extended bynet.sf.click.extras.service.Log4JLogService
All Implemented Interfaces:
LogService

public class Log4JLogService
extends Object
implements LogService

Provides a Log4J LogService adapter class. This logger will use the category name of "Click".

Configuration

To configure the Log4J LoggingService add the following element to your click.xml configuration file.
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <click-app charset="UTF-8">

     <pages package="net.sf.click.examples.page"/>

     <log-service classname="net.sf.click.extras.service.Log4JLogService"/>

 </click-app> 

Author:
Malcolm Edgar

Field Summary
protected  org.apache.log4j.Logger logger
          The wrapped Log4J logger instance.
protected  String name
          The logger category name.
 
Constructor Summary
Log4JLogService()
           
 
Method Summary
 void debug(Object message)
           
 void debug(Object message, Throwable error)
           
 void error(Object message)
           
 void error(Object message, Throwable error)
           
 String getName()
          Return the logger category name.
 void info(Object message)
           
 void info(Object message, Throwable error)
           
 boolean isDebugEnabled()
           
 boolean isInfoEnabled()
           
 boolean isTraceEnabled()
           
 void onDestroy()
           
 void onInit(ServletContext servletContext)
           
 void setName(String name)
          The logger category name.
 void trace(Object message)
           
 void trace(Object message, Throwable error)
           
 void warn(Object message)
           
 void warn(Object message, Throwable error)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected org.apache.log4j.Logger logger
The wrapped Log4J logger instance.


name

protected String name
The logger category name. The default value is "Click".

Constructor Detail

Log4JLogService

public Log4JLogService()
Method Detail

onInit

public void onInit(ServletContext servletContext)
            throws Exception
Specified by:
onInit in interface LogService
Parameters:
servletContext - the application servlet context
Throws:
Exception - if an error occurs initializing the LogService
See Also:
LogService.onInit(javax.servlet.ServletContext)

onDestroy

public void onDestroy()
Specified by:
onDestroy in interface LogService
See Also:
LogService.onDestroy()

debug

public void debug(Object message)
Specified by:
debug in interface LogService
Parameters:
message - the message to log
See Also:
LogService.debug(Object)

debug

public void debug(Object message,
                  Throwable error)
Specified by:
debug in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.debug(Object, Throwable)

error

public void error(Object message)
Specified by:
error in interface LogService
Parameters:
message - the message to log
See Also:
LogService.error(Object)

error

public void error(Object message,
                  Throwable error)
Specified by:
error in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.error(Object, Throwable)

info

public void info(Object message)
Specified by:
info in interface LogService
Parameters:
message - the message to log
See Also:
LogService.info(Object)

info

public void info(Object message,
                 Throwable error)
Specified by:
info in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.info(Object, Throwable)

isDebugEnabled

public boolean isDebugEnabled()
Specified by:
isDebugEnabled in interface LogService
Returns:
true if [debug] level logging is enabled
See Also:
LogService.isDebugEnabled()

isInfoEnabled

public boolean isInfoEnabled()
Specified by:
isInfoEnabled in interface LogService
Returns:
true if [info] level logging is enabled
See Also:
LogService.isInfoEnabled()

isTraceEnabled

public boolean isTraceEnabled()
Specified by:
isTraceEnabled in interface LogService
Returns:
true if [trace] level logging is enabled
See Also:
LogService.isTraceEnabled()

trace

public void trace(Object message)
Specified by:
trace in interface LogService
Parameters:
message - the message to log
See Also:
LogService.trace(Object)

trace

public void trace(Object message,
                  Throwable error)
Specified by:
trace in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.trace(Object, Throwable)

warn

public void warn(Object message)
Specified by:
warn in interface LogService
Parameters:
message - the message to log
See Also:
LogService.warn(Object)

warn

public void warn(Object message,
                 Throwable error)
Specified by:
warn in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.warn(Object, Throwable)

getName

public String getName()
Return the logger category name.

Returns:
the logger category name

setName

public void setName(String name)
The logger category name. Setting the name after the onInit() method has bee invoked will have no effect on the Log4J loggers name.

Parameters:
name - the logger category name to set