Package org.eclipse.jetty.util.log
Class StdErrLog
java.lang.Object
org.eclipse.jetty.util.log.AbstractLogger
org.eclipse.jetty.util.log.StdErrLog
- All Implemented Interfaces:
Logger
StdErr Logging implementation.
A Jetty Logger that sends all logs to STDERR (System.err) with basic formatting.
Supports named loggers, and properties based configuration.
Configuration Properties:
- ${name|hierarchy}.LEVEL=(ALL|DEBUG|INFO|WARN|OFF)
-
Sets the level that the Logger should log at.
Names can be a package name, or a fully qualified class name.
Default: INFO
Examples:- org.eclipse.jetty.LEVEL=WARN
- indicates that all of the jetty specific classes, in any package that
starts with
org.eclipse.jettyshould log at level WARN. - org.eclipse.jetty.io.ChannelEndPoint.LEVEL=ALL
- indicates that the specific class, ChannelEndPoint, should log all logging events that it can generate, including DEBUG, INFO, WARN (and even special internally ignored exception cases).
- ${name}.SOURCE=(true|false)
-
Logger specific, attempt to print the java source file name and line number
where the logging event originated from.
Name must be a fully qualified class name (package name hierarchy is not supported by this configurable)
Warning: this is a slow operation and will have an impact on performance!
Default: false - ${name}.STACKS=(true|false)
-
Logger specific, control the display of stacktraces.
Name must be a fully qualified class name (package name hierarchy is not supported by this configurable)
Default: true - org.eclipse.jetty.util.log.stderr.SOURCE=(true|false)
- Special Global Configuration, attempt to print the java source file name and line number
where the logging event originated from.
Default: false - org.eclipse.jetty.util.log.stderr.LONG=(true|false)
- Special Global Configuration, when true, output logging events to STDERR using
long form, fully qualified class names. when false, use abbreviated package names
Default: false - org.eclipse.jetty.util.log.stderr.ESCAPE=(true|false)
- Global Configuration, when true output logging events to STDERR are always
escaped so that control characters are replaced with '?"; '\r' with '<' and '\n' replaced '|'
Default: true
-
Field Summary
FieldsFields inherited from class org.eclipse.jetty.util.log.AbstractLogger
LEVEL_ALL, LEVEL_DEBUG, LEVEL_DEFAULT, LEVEL_INFO, LEVEL_OFF, LEVEL_WARN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidFormats and logs at debug level.voidFormats and logs at debug level.voidLogs the given message at debug level, with Throwable information.voidLogs the given Throwable information at debug levelintgetLevel()static StdErrLogObtain a StdErrLog reference for the specified class, a convenience method used most often during testing to allow for control over a specific logger.static intgetLoggingLevel(Properties props, String name) getName()voidIgnore an exception.voidFormats and logs at info level.voidLogs the given message at info level, with Throwable information.voidLogs the given Throwable information at info levelbooleanbooleanbooleanbooleanisSource()Is the source of a log, loggedprotected LoggerCreate a Child Logger of this Logger.voidsetDebugEnabled(boolean enabled) Legacy interface where a programmatic configuration of the logger level is done as a wholesale approach.voidsetHideStacks(boolean hideStacks) voidsetLevel(int level) Set the level for this logger.voidsetPrintLongNames(boolean printLongNames) voidsetSource(boolean source) Set if a log source is logged.voidsetStdErrStream(PrintStream stream) The alternate stream to use for STDERR.static voidsetTagPad(int pad) toString()voidFormats and logs at warn level.voidLogs the given message at warn level, with Throwable information.voidLogs the given Throwable information at warn levelMethods inherited from class org.eclipse.jetty.util.log.AbstractLogger
condensePackageString, getLevelId, getLogger, getLoggingProperty, lookupLoggingLevel
-
Field Details
-
_abbrevname
-
-
Constructor Details
-
StdErrLog
public StdErrLog()Construct an anonymous StdErrLog (no name).NOTE: Discouraged usage!
-
StdErrLog
Construct a named StdErrLog using theLogdefined properties- Parameters:
name- the name of the logger
-
StdErrLog
Construct a named Logger using the provided properties to configure logger.- Parameters:
name- the name of the loggerprops- the configuration properties
-
-
Method Details
-
setTagPad
public static void setTagPad(int pad) -
getLoggingLevel
-
getLogger
Obtain a StdErrLog reference for the specified class, a convenience method used most often during testing to allow for control over a specific logger.Must be actively using StdErrLog as the Logger implementation.
- Parameters:
clazz- the Class reference for the logger to use.- Returns:
- the StdErrLog logger
- Throws:
RuntimeException- if StdErrLog is not the active Logger implementation.
-
getName
- Returns:
- the name of this logger
-
setPrintLongNames
public void setPrintLongNames(boolean printLongNames) -
isPrintLongNames
public boolean isPrintLongNames() -
isHideStacks
public boolean isHideStacks() -
setHideStacks
public void setHideStacks(boolean hideStacks) -
isSource
public boolean isSource()Is the source of a log, logged- Returns:
- true if the class, method, file and line number of a log is logged.
-
setSource
public void setSource(boolean source) Set if a log source is logged.- Parameters:
source- true if the class, method, file and line number of a log is logged.
-
warn
Description copied from interface:LoggerFormats and logs at warn level.- Parameters:
msg- the formatting stringargs- the optional arguments
-
warn
Description copied from interface:LoggerLogs the given Throwable information at warn level- Parameters:
thrown- the Throwable to log
-
warn
Description copied from interface:LoggerLogs the given message at warn level, with Throwable information.- Parameters:
msg- the message to logthrown- the Throwable to log
-
info
Description copied from interface:LoggerFormats and logs at info level.- Parameters:
msg- the formatting stringargs- the optional arguments
-
info
Description copied from interface:LoggerLogs the given Throwable information at info level- Parameters:
thrown- the Throwable to log
-
info
Description copied from interface:LoggerLogs the given message at info level, with Throwable information.- Parameters:
msg- the message to logthrown- the Throwable to log
-
isDebugEnabled
- Returns:
- whether the debug level is enabled
-
setDebugEnabled
public void setDebugEnabled(boolean enabled) Legacy interface where a programmatic configuration of the logger level is done as a wholesale approach.- Parameters:
enabled- whether to enable the debug level
-
getLevel
public int getLevel() -
setLevel
public void setLevel(int level) Set the level for this logger.Available values (
AbstractLogger.LEVEL_ALL,AbstractLogger.LEVEL_DEBUG,AbstractLogger.LEVEL_INFO,AbstractLogger.LEVEL_WARN)- Parameters:
level- the level to set the logger to
-
setStdErrStream
The alternate stream to use for STDERR.- Parameters:
stream- the stream of choice, ornullto useSystem.err
-
debug
Description copied from interface:LoggerFormats and logs at debug level.- Parameters:
msg- the formatting stringargs- the optional arguments
-
debug
Description copied from interface:LoggerFormats and logs at debug level. avoids autoboxing of integers- Specified by:
debugin interfaceLogger- Overrides:
debugin classAbstractLogger- Parameters:
msg- the formatting stringarg- long value
-
debug
Description copied from interface:LoggerLogs the given Throwable information at debug level- Parameters:
thrown- the Throwable to log
-
debug
Description copied from interface:LoggerLogs the given message at debug level, with Throwable information.- Parameters:
msg- the message to logthrown- the Throwable to log
-
newLogger
Create a Child Logger of this Logger.- Specified by:
newLoggerin classAbstractLogger
-
toString
-
ignore
Description copied from interface:LoggerIgnore an exception.This should be used rather than an empty catch block.
- Parameters:
ignored- the throwable to log as ignored
-