WebObjects 5.2.3

com.webobjects.foundation
Class NSLog.Log4JLogger

java.lang.Object
  extended bycom.webobjects.foundation.NSLog.Logger
      extended bycom.webobjects.foundation.NSLog.Log4JLogger
Enclosing class:
NSLog

public static class NSLog.Log4JLogger
extends NSLog.Logger

NSLog.Log4JLogger is a concrete subclass of NSLog.Logger. It logs output to an org.apache.log4j.Logger contained by this NSLog.Logger. Thisorg.apache.log4j.Logger can be changed, which causes the receiver to direct log messages.

NOTE: allowedDebugLevel is significant for any NSLog.Log4JLogger, not just an instance assigned to NSLog.debug. appendln(Object) requires a debug level internally to determine which public log method to use, because org.apache.log4j.Logger.forcedLog is protected. Make sure that you use the NSLog.Log4JLogger(int) constructor or manually invoke setAllowedDebugLevel on any new NSLog.Log4JLogger instance; this instance may fail to log output until this happens.

Since:
5.2.2
See Also:
allowedDebugLevel(), appendln(Object), setAllowedDebugLevel(int), NSLog, NSLog.Logger, NSLog.Logger.allowedDebugLevel()

Field Summary
protected  org.apache.log4j.Logger logger
           
protected  org.apache.log4j.Level logLevel
           
 
Fields inherited from class com.webobjects.foundation.NSLog.Logger
debugLevel, isEnabled, isVerbose
 
Constructor Summary
NSLog.Log4JLogger()
           
NSLog.Log4JLogger(org.apache.log4j.Logger aLogger, int level)
          Creates a new NSLog.Log4JLogger which directs output to aLogger.
 
Method Summary
 int allowedDebugLevel()
          Invokes getLevel().toInt() on log4jLogger, and maps the result to the equivalent NSLog debug level.
 void appendln()
          Invokes appendln(Object) with an empty string.
 void appendln(Object aValue)
          Passes aValue as the Object parameter to the appropriate method of log4jLogger, if isEnabled returns true.
protected static int convertLog4JLevelToNSLogLevel(int aLog4JDebugLevel)
           
protected static int convertNSLogLevelToLog4JLevel(int anNSLogDebugLevel)
           
 void flush()
          Does nothing.
 org.apache.log4j.Logger log4jLogger()
          Provides the org.apache.log4j.Logger wrapped by this NSLog.Log4JLogger instance.
 void setAllowedDebugLevel(int aDebugLevel)
          Passes aDebugLevel to setLevel on log4jLogger.
 void setLog4jLogger(org.apache.log4j.Logger aLogger)
          Redirects output from this NSLog.Log4JLogger instance to aLogger.
 
Methods inherited from class com.webobjects.foundation.NSLog.Logger
appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, isEnabled, isVerbose, setIsEnabled, setIsVerbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logLevel

protected org.apache.log4j.Level logLevel

logger

protected org.apache.log4j.Logger logger
Constructor Detail

NSLog.Log4JLogger

public NSLog.Log4JLogger()

NSLog.Log4JLogger

public NSLog.Log4JLogger(org.apache.log4j.Logger aLogger,
                         int level)
Creates a new NSLog.Log4JLogger which directs output to aLogger. aLogger should be completely preconfigured. No assumptions will be made about its configuration; consequently, this constructor invokes super.setIsVerbose(false).

Throws:
IllegalArgumentException - if aLogger is null
See Also:
#(int), log4jLogger(), NSLog.Logger.setIsVerbose(boolean), NSLog#Logger()
Method Detail

allowedDebugLevel

public int allowedDebugLevel()
Invokes getLevel().toInt() on log4jLogger, and maps the result to the equivalent NSLog debug level.

This mapping is as follows:

Log4J Debug LevelNSLog Debug Level
nullDebugLevelOff
org.apache.log4j.Level.OFFDebugLevelOff
org.apache.log4j.Level.ERRORDebugLevelCritical
org.apache.log4j.Level.FATALDebugLevelCritical
org.apache.log4j.Level.INFODebugLevelInformational
org.apache.log4j.Level.WARNDebugLevelInformational
org.apache.log4j.Level.ALLDebugLevelDetailed
org.apache.log4j.Level.DEBUGDebugLevelDetailed

Overrides:
allowedDebugLevel in class NSLog.Logger
Returns:
one of the debug levels specified in NSLog
Throws:
IllegalArgumentException - if log4jLogger provides a value other than those specified in org.apache.log4j.Level
See Also:
log4jLogger(), setAllowedDebugLevel(int), NSLog.Logger.allowedDebugLevel(), NSLog

appendln

public void appendln()
Invokes appendln(Object) with an empty string.

Specified by:
appendln in class NSLog.Logger
See Also:
appendln(Object), NSLog.Logger.appendln()

appendln

public void appendln(Object aValue)
Passes aValue as the Object parameter to the appropriate method of log4jLogger, if isEnabled returns true.

Specified by:
appendln in class NSLog.Logger
Parameters:
aValue - the object to be logged
See Also:
log4jLogger(), NSLog.Logger.appendln(Object), NSLog.Logger.isEnabled

convertLog4JLevelToNSLogLevel

protected static int convertLog4JLevelToNSLogLevel(int aLog4JDebugLevel)

convertNSLogLevelToLog4JLevel

protected static int convertNSLogLevelToLog4JLevel(int anNSLogDebugLevel)

flush

public void flush()
Does nothing. org.apache.log4j.Logger does not provide a mechanism to flush output on demand. By default, org.apache.log4j.Logger does flush each fragment of output automatically.

Specified by:
flush in class NSLog.Logger
See Also:
NSLog.Logger.flush()

log4jLogger

public org.apache.log4j.Logger log4jLogger()
Provides the org.apache.log4j.Logger wrapped by this NSLog.Log4JLogger instance. The methods for this object use the org.apache.log4j.Logger instance directly, rather than via this accessor method.

Returns:
an instance of org.apache.log4j.Logger; never null
See Also:
#(int), #(org.apache.log4j.Logger), setLog4jLogger(org.apache.log4j.Logger), NSLog.Logger#()

setAllowedDebugLevel

public void setAllowedDebugLevel(int aDebugLevel)
Passes aDebugLevel to setLevel on log4jLogger. aDebugLevel may be either an NSLog debug level or an integer level from org.apache.log4j.Level. Maps an NSLog debug level to the equivalent org.apache.log4j.Level integer, or passes through a value from org.apache.log4j.Level.

This mapping is as follows:

NSLog Debug LevelLog4J Debug Level
DebugLevelOfforg.apache.log4j.Level.OFF
DebugLevelCriticalorg.apache.log4j.Level.ERROR
DebugLevelInformationalorg.apache.log4j.Level.INFO
DebugLevelDetailedorg.apache.log4j.Level.ALL

Overrides:
setAllowedDebugLevel in class NSLog.Logger
Parameters:
aDebugLevel - level of debug required
Throws:
IllegalArgumentException - if aDebugLevel is not a valid level for NSLog
See Also:
allowedDebugLevel(), log4jLogger(), NSLog.Logger.setAllowedDebugLevel(int), NSLog

setLog4jLogger

public void setLog4jLogger(org.apache.log4j.Logger aLogger)
Redirects output from this NSLog.Log4JLogger instance to aLogger. No change is made if aLogger is null. aLogger should be completely preconfigured. No assumptions will be made about its configuration;.

Parameters:
aLogger - an instance of org.apache.log4j.Logger
See Also:
#(org.apache.log4j.Logger), log4jLogger()

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.