Package net.sf.saxon.lib
Class StandardLogger
java.lang.Object
net.sf.saxon.lib.Logger
net.sf.saxon.lib.StandardLogger
The default Logger used by Saxon on the Java platform. All messages are written by default
to System.err. The logger can be configured by setting a different output destination, and
by setting a minimum threshold for the severity of messages to be output.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a Logger that wraps the System.err output streamStandardLogger
(File fileName) Create a Logger that writes to a specified fileStandardLogger
(PrintStream stream) Create a Logger that wraps the specified stream.StandardLogger
(Writer writer) Create a Logger that wraps the specified writer. -
Method Summary
Modifier and TypeMethodDescriptionGet a JAXP Result object allowing serialized XML to be written to the output destination of this Loggervoid
close()
Close the logger, indicating that no further messages will be writtenGet the output destination used for messagesint
Get the minimum threshold for the severity of messages to be output.void
Output a message with a specified severity.void
setPrintStream
(PrintStream stream) Set the output destination for messagesvoid
setPrintWriter
(PrintWriter writer) Set the output destination for messagesvoid
setThreshold
(int threshold) Set the minimum threshold for the severity of messages to be output.Methods inherited from class net.sf.saxon.lib.Logger
asWriter, disaster, error, info, isUnicodeAware, setUnicodeAware, warning
-
Constructor Details
-
StandardLogger
public StandardLogger()Create a Logger that wraps the System.err output stream -
StandardLogger
Create a Logger that wraps the specified stream. Closing the Logger will not close the underlying stream; this remains the caller's responsibility- Parameters:
stream
- the stream to which the Logger's output should be written
-
StandardLogger
Create a Logger that wraps the specified writer. Closing the Logger will not close the underlying stream; this remains the caller's responsibility- Parameters:
writer
- the writer to which the Logger's output should be written
-
StandardLogger
Create a Logger that writes to a specified file- Parameters:
fileName
- the file to which output should be written. When the logger is closed, output will be flushed to the file.- Throws:
FileNotFoundException
- if the file is not accessible
-
-
Method Details
-
setPrintStream
Set the output destination for messages- Parameters:
stream
- the stream to which messages will be written. Defaults to System.err. The caller is responsible for closing the stream after use (it will not be closed by the close() method on the Logger)
-
setPrintWriter
Set the output destination for messages- Parameters:
writer
- the stream to which messages will be written. Defaults to System.err. The caller is responsible for closing the stream after use (it will not be closed by the close() method on the Logger)
-
getPrintWriter
Get the output destination used for messages- Returns:
- the stream to which messages are written
-
setThreshold
public void setThreshold(int threshold) Set the minimum threshold for the severity of messages to be output. Defaults toLogger.INFO
. Messages whose severity is below this threshold will be ignored- Parameters:
threshold
- the minimum severity of messages to be output.
-
getThreshold
public int getThreshold()Get the minimum threshold for the severity of messages to be output. Defaults toLogger.INFO
. Messages whose severity is below this threshold will be ignored- Returns:
- the minimum severity of messages to be output.
-
asStreamResult
Get a JAXP Result object allowing serialized XML to be written to the output destination of this Logger- Overrides:
asStreamResult
in classLogger
- Returns:
- a Result that serializes XML to this Logger
-
println
Output a message with a specified severity.- Specified by:
println
in classLogger
- Parameters:
message
- The message to be outputseverity
- The severity: one ofLogger.INFO
,Logger.WARNING
,Logger.ERROR
,Logger.DISASTER
-
close
public void close()Close the logger, indicating that no further messages will be written
-