Documentation Archive Developer
Search
PATH Documentation > WebObjects

Table of Contents

NSLog.PrintStreamLogger


Inherits from:
NSLog.Logger
Package:
com.webobjects.foundation


Class Description


NSLog.PrintStreamLogger is a concrete subclass of NSLog.Logger. It logs output to a java.io.PrintStream which is contained by the logger. This PrintStream can be changed, which causes the receiver to output log messages somewhere else, such as a local file. Methods are provided to enable and disable logging, and to enable and disable verbose logging.

NSLog.out and NSLog.debug are PrintStreamLoggers that point at System.out. NSLog.err is a PrintStreamLogger that points to System.err.

NSLog.PrintStreamLogger looks at the value of the internal variables set by NSLog.Logger.setIsVerbose() and NSLog.Logger.setIsEnabled() to determine whether to produce verbose output and to determine whether to log messages to the logger. See the method descriptions for these methods in the documentation for "NSLog.Logger" (page 139).




Method Types


All methods
NSLog.PrintStreamLogger
appendln
appendln
flush
printStream
setPrintStream


Constructors



NSLog.PrintStreamLogger

public NSLog.PrintStreamLogger(java.io.PrintStream aPrintStream)

Creates a new NSLog.PrintStreamLogger which directs output to aPrintStream. Throws an IllegalArgumentException if aPrintStream is null.

public NSLog.PrintStreamLogger()

Creates a new NSLog.PrintStreamLogger which directs output to System.out.


Instance Methods



appendln

public void appendln()

Writes a new line to the receiver's PrintStream.

appendln

public void appendln(Throwable aThrowable)

Writes the stack trace of aThrowable to the receiver's PrintStream.

appendln

public void appendln(Object anObject)

Writes anObject to the receiver's PrintStream.

flush

public void flush()

Flush's the receiver's PrintStream by invoking the PrintStream's flush method.

printStream

public java.io.PrintStream printStream()

Returns the receiver's PrintStream.

setPrintStream

public void setPrintStream(java.io.PrintStream aPrintStream)

Sets the receiver's print stream to aPrintStream. This redirects the receiver's output. For example, to redirect all log messages to the local file /Local/Users/log.txt, use the following code:

NSLog.PrintStreamLogger aLogger = 
    new NSLog.PrintStreamLogger(); // Output defaults to System.out
PrintStream aStream = 
    NSLog.printStreamForPath ("/Local/Users/log.txt"); // New print stream based on path.
aLogger.setPrintStream (aStream); // Direct output to the custom PrintStream.
NSLog.setOut(aLogger); // Assign the custom PrintStreamLogger to the declared instances of NSLogger in NSLog
NSLog.setErr(aLogger);
NSLog.setDebug(aLogger);
aLogger.appendln(anObject);



© 2001 Apple Computer, Inc. (Last Published April 17, 2001)


Table of Contents