org.owasp.esapi.reference
Class Log4JLogFactory

java.lang.Object
  extended by org.owasp.esapi.reference.Log4JLogFactory
All Implemented Interfaces:
LogFactory

public class Log4JLogFactory
extends java.lang.Object
implements LogFactory

Reference implementation of the LogFactory interface. This implementation uses the Apache Log4J package, and marks each log message with the currently logged in user and the word "SECURITY" for security related events. See the JavaLogFactory.JavaLogger Javadocs for the details on the JavaLogger reference implementation. At class initialization time, the file log4j.properties or log4j.xml file will be loaded from the classpath. This configuration file is fundamental to make log4j work for you. Please see http://logging.apache.org/log4j/1.2/manual.html for more information. Note that you must specify the LogFactory in either log4j.properties: log4j.loggerFactory=org.owasp.esapi.reference.Log4JLoggerFactory or log4j.xml: <loggerFactory class="org.owasp.esapi.reference.Log4JLoggerFactory"/>

Since:
June 1, 2007
Author:
Mike H. Fauzy ([email protected]) Aspect Security, Jim Manico ([email protected]) Manico.net, Jeff Williams (jeff.williams .at. aspectsecurity.com) Aspect Security, August Detlefsen (augustd at codemagi dot com) CodeMagi, Inc.
See Also:
LogFactory, Log4JLogger, Log4JLoggerFactory

Constructor Summary
protected Log4JLogFactory()
           
 
Method Summary
static LogFactory getInstance()
           
 Logger getLogger(java.lang.Class clazz)
          Gets the logger associated with the specified class.
 Logger getLogger(java.lang.String moduleName)
          Gets the logger associated with the specified module name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4JLogFactory

protected Log4JLogFactory()
Method Detail

getInstance

public static LogFactory getInstance()

getLogger

public Logger getLogger(java.lang.Class clazz)
Gets the logger associated with the specified class. The class is used by the logger to log which class is generating the log events. The implementation of this method should return any preexisting Logger associated with this class name, rather than creating a new Logger.

The JavaLogFactory reference implementation meets these requirements.

Specified by:
getLogger in interface LogFactory
Parameters:
clazz - The name of the class requesting the logger.
Returns:
The Logger associated with this class.

getLogger

public Logger getLogger(java.lang.String moduleName)
Gets the logger associated with the specified module name. The module name is used by the logger to log which module is generating the log events. The implementation of this method should return any preexisting Logger associated with this module name, rather than creating a new Logger.

The JavaLogFactory reference implementation meets these requirements.

Specified by:
getLogger in interface LogFactory
Parameters:
moduleName - The name of the module requesting the logger.
Returns:
The Logger associated with this module.


Copyright © 2011 The Open Web Application Security Project (OWASP). All Rights Reserved.