biz.chitec.quarterback.util
Class LogFileWriter
java.lang.Object
biz.chitec.quarterback.util.LogFileWriter
- All Implemented Interfaces:
- LoggingReceiver
- public class LogFileWriter
- extends java.lang.Object
- implements LoggingReceiver
Log object which can write into file and onto console. Standard stream logging is possible.
LogFileWriter takes an object in its handleLogObject method and writes it
somewhere. Normally, the object is written onto the console. If is, however,
possible to use a log file where the object is written, too.
Through the static methods open/closeStandardStreamsLogFileWriter() any
output to the standard streams can be passed through a LogFileWriter object.
This way, it is possible to log standard output, e.g. Exception stack traces,
into a file. If a Throwable object is thrown directly into the LogFileWriter,
it tries to obtain and log its stack trace automatically.
This receiver is hardcoded not to write more than the first 500 characters
of each line of the message to be logged.
- Version:
- $Id: 96a33caa8208b98273f39e5b02e92c8b938bf2a0 $
- Author:
- Dirk Hillbrecht 1998-2000, chitec/Dirk Hillbrecht 2000, cantamen/Dirk Hillbrecht 2004.
Distributed under the terms of the GNU LGPL.
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
oldstdout
static java.io.PrintStream oldstdout
oldstderr
static java.io.PrintStream oldstderr
stdholder
static LogFileWriter stdholder
ssl
static LogFileWriter.StandardStreamLogger ssl
newstd
static java.io.PrintStream newstd
consoleout
boolean consoleout
filelogging
boolean filelogging
filename
java.lang.String filename
fileout
java.io.PrintWriter fileout
oldnowstring
java.lang.String oldnowstring
LogFileWriter
public LogFileWriter()
close
public void close()
finalize
protected void finalize()
throws java.io.IOException
- Throws:
java.io.IOException
setConsoleOut
public void setConsoleOut(boolean co)
getConsoleOut
public boolean getConsoleOut()
setFileLogging
public void setFileLogging(boolean fl)
getFileLogging
public boolean getFileLogging()
setFilename
public void setFilename(java.lang.String fn)
getFilename
public java.lang.String getFilename()
closeOutputFile
public void closeOutputFile()
throws java.io.IOException
- Throws:
java.io.IOException
openOutputFile
public void openOutputFile()
throws java.io.IOException
- Throws:
java.io.IOException
handleLogObject
public void handleLogObject(Logger src,
java.lang.Object o)
- Description copied from interface:
LoggingReceiver
- logging receiving method.
- Specified by:
handleLogObject
in interface LoggingReceiver
openStandardStreamsLogFileWriter
public static LogFileWriter openStandardStreamsLogFileWriter()
throws java.io.IOException
- Throws:
java.io.IOException
closeStandardStreamsLogFileWriter
public static void closeStandardStreamsLogFileWriter()