oracle.dacf.util.errorloggers
Class OutputStreamLogger
java.lang.Object
|
+--oracle.dacf.util.errormanager.ErrorLoggerAdapter
|
+--oracle.dacf.util.errorloggers.OutputStreamLogger
- All Implemented Interfaces:
- ErrorLogger
- public class OutputStreamLogger
- extends ErrorLoggerAdapter
The OutPutStreamLogger is a non-buffered logger class
that writes error information to an OutputStream. This class extends
ErrorLoggerAdapter, which defines an abstract non-buffered logger, and
provides implementations of the addError and getName methods.
For example, the following logger code writes to an OutputStream.
You can use it to write logging information to any Java Outputstream,
for example, a socket, a file, and so on.
OutputStreamLogger logger = null;
try
{
FileOutputStream fo = new FileOutputStream("tst.out");
logger = new OutputStreamLogger(fo);
}
catch (java.io.IOException e)
{
System.err.println("#$%%%$@%@|?!!!!");
}
try
{
ErrorManager.addErrorLogger(logger);
}
catch (NameAlreadyRegisteredException e)
{
System.err.println("A Logger with this
name is already registered.");
return;
}
……………..
……………..
……………..
// close the OutputStream, to force flushing
logger.closeOutputStream();
ErrorManager.removeErrorLogger(logger);
- See Also:
ErrorLogger
,
ErrorLoggerAdapter
Field Summary |
static java.lang.String |
NAME
String returned by the getName() method. |
Constructor Summary |
OutputStreamLogger(java.io.OutputStream os)
Public constructor which takes an OutputStream object; it will use the
default character encoding. |
OutputStreamLogger(java.io.OutputStreamWriter ow)
Public constructor which takes an OutputStreamWriter object. |
Method Summary |
void |
addError(ErrorMessage emsg)
When adding an error, the error severity, message text, and time stamp
will be written to the OutputStream. |
void |
closeOutputStream()
Closes and flushes the OutputStream. |
java.lang.String |
getName()
Returns the unique name of the error logger. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NAME
public static java.lang.String NAME
- String returned by the getName() method.
OutputStreamLogger
public OutputStreamLogger(java.io.OutputStream os)
- Public constructor which takes an OutputStream object; it will use the
default character encoding.
- Parameters:
os
- the OutputStream or logging target.
OutputStreamLogger
public OutputStreamLogger(java.io.OutputStreamWriter ow)
- Public constructor which takes an OutputStreamWriter object.
- Parameters:
os
- the OutputStreamWriter or logging target.
addError
public void addError(ErrorMessage emsg)
- When adding an error, the error severity, message text, and time stamp
will be written to the OutputStream.
- Overrides:
addError
in class ErrorLoggerAdapter
- Parameters:
emsg
- the error message.
closeOutputStream
public void closeOutputStream()
- Closes and flushes the OutputStream.
getName
public java.lang.String getName()
- Returns the unique name of the error logger. An error logger without a name cannot be
registered by the error manager.
- Returns:
- the name of this error logger.