org.eclipse.jetty.util.log
Class StdErrLog

java.lang.Object
  extended by org.eclipse.jetty.util.log.StdErrLog
All Implemented Interfaces:
Logger

public class StdErrLog
extends Object
implements Logger

StdErr Logging. This implementation of the Logging facade sends all logs to StdErr with minimal formatting.

If the system property "org.eclipse.jetty.LEVEL" is set to one of the following (ALL, DEBUG, INFO, WARN), then set the eclipse jetty root level logger level to that specified level. (Default level is INFO)

If the system property "org.eclipse.jetty.util.log.SOURCE" is set, then the source method/file of a log is logged. For named debuggers, the system property name+".SOURCE" is checked. If it is not not set, then "org.eclipse.jetty.util.log.SOURCE" is used as the default.

If the system property "org.eclipse.jetty.util.log.LONG" is set, then the full, unabbreviated name of the logger is used for logging. For named debuggers, the system property name+".LONG" is checked. If it is not not set, then "org.eclipse.jetty.util.log.LONG" is used as the default.


Field Summary
static int LEVEL_ALL
           
static int LEVEL_DEBUG
           
static int LEVEL_INFO
           
static int LEVEL_WARN
           
 
Constructor Summary
StdErrLog()
           
StdErrLog(String name)
           
 
Method Summary
protected static String condensePackageString(String classname)
          Condenses a classname by stripping down the package name to just the first character of each package name segment.Configured
 void debug(String msg, Object... args)
          Formats and logs at debug level.
 void debug(String msg, Throwable thrown)
          Logs the given message at debug level, with Throwable information.
 void debug(Throwable thrown)
          Logs the given Throwable information at debug level
 int getLevel()
           
protected static int getLevelId(String levelName)
           
 Logger getLogger(String name)
           
static int getLoggingLevel(Properties props, String name)
          Get the Logging Level for the provided log name.
 String getName()
           
 void ignore(Throwable ignored)
          Ignore an exception.
 void info(String msg, Object... args)
          Formats and logs at info level.
 void info(String msg, Throwable thrown)
          Logs the given message at info level, with Throwable information.
 void info(Throwable thrown)
          Logs the given Throwable information at info level
 boolean isDebugEnabled()
           
 boolean isHideStacks()
           
 boolean isPrintLongNames()
           
 boolean isSource()
          Is the source of a log, logged
 void setDebugEnabled(boolean enabled)
          Deprecated. use setLevel(int) instead.
 void setHideStacks(boolean hideStacks)
           
 void setLevel(int level)
          Set the level for this logger.
 void setPrintLongNames(boolean printLongNames)
           
 void setSource(boolean source)
          Set if a log source is logged.
 void setStdErrStream(PrintStream stream)
           
 String toString()
           
 void warn(String msg, Object... args)
          Formats and logs at warn level.
 void warn(String msg, Throwable thrown)
          Logs the given message at warn level, with Throwable information.
 void warn(Throwable thrown)
          Logs the given Throwable information at warn level
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEVEL_ALL

public static final int LEVEL_ALL
See Also:
Constant Field Values

LEVEL_DEBUG

public static final int LEVEL_DEBUG
See Also:
Constant Field Values

LEVEL_INFO

public static final int LEVEL_INFO
See Also:
Constant Field Values

LEVEL_WARN

public static final int LEVEL_WARN
See Also:
Constant Field Values
Constructor Detail

StdErrLog

public StdErrLog()

StdErrLog

public StdErrLog(String name)
Method Detail

getLoggingLevel

public static int getLoggingLevel(Properties props,
                                  String name)
Get the Logging Level for the provided log name. Using the FQCN first, then each package segment from longest to shortest.

Parameters:
props - the properties to check
name - the name to get log for
Returns:
the logging level

getLevelId

protected static int getLevelId(String levelName)

condensePackageString

protected static String condensePackageString(String classname)
Condenses a classname by stripping down the package name to just the first character of each package name segment.Configured

 Examples:
 "org.eclipse.jetty.test.FooTest"           = "oejt.FooTest"
 "org.eclipse.jetty.server.logging.LogTest" = "orjsl.LogTest"
 

Parameters:
classname - the fully qualified class name
Returns:
the condensed name

getName

public String getName()
Specified by:
getName in interface Logger
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

public void warn(String msg,
                 Object... args)
Description copied from interface: Logger
Formats and logs at warn level.

Specified by:
warn in interface Logger
Parameters:
msg - the formatting string
args - the optional arguments

warn

public void warn(Throwable thrown)
Description copied from interface: Logger
Logs the given Throwable information at warn level

Specified by:
warn in interface Logger
Parameters:
thrown - the Throwable to log

warn

public void warn(String msg,
                 Throwable thrown)
Description copied from interface: Logger
Logs the given message at warn level, with Throwable information.

Specified by:
warn in interface Logger
Parameters:
msg - the message to log
thrown - the Throwable to log

info

public void info(String msg,
                 Object... args)
Description copied from interface: Logger
Formats and logs at info level.

Specified by:
info in interface Logger
Parameters:
msg - the formatting string
args - the optional arguments

info

public void info(Throwable thrown)
Description copied from interface: Logger
Logs the given Throwable information at info level

Specified by:
info in interface Logger
Parameters:
thrown - the Throwable to log

info

public void info(String msg,
                 Throwable thrown)
Description copied from interface: Logger
Logs the given message at info level, with Throwable information.

Specified by:
info in interface Logger
Parameters:
msg - the message to log
thrown - the Throwable to log

isDebugEnabled

public boolean isDebugEnabled()
Specified by:
isDebugEnabled in interface Logger
Returns:
whether the debug level is enabled

setDebugEnabled

@Deprecated
public void setDebugEnabled(boolean enabled)
Deprecated. use setLevel(int) instead.

Description copied from interface: Logger
Mutator used to turn debug on programmatically.

Specified by:
setDebugEnabled in interface Logger
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 (LEVEL_ALL, LEVEL_DEBUG, LEVEL_INFO, LEVEL_WARN)

Parameters:
level - the level to set the logger to

setStdErrStream

public void setStdErrStream(PrintStream stream)

debug

public void debug(String msg,
                  Object... args)
Description copied from interface: Logger
Formats and logs at debug level.

Specified by:
debug in interface Logger
Parameters:
msg - the formatting string
args - the optional arguments

debug

public void debug(Throwable thrown)
Description copied from interface: Logger
Logs the given Throwable information at debug level

Specified by:
debug in interface Logger
Parameters:
thrown - the Throwable to log

debug

public void debug(String msg,
                  Throwable thrown)
Description copied from interface: Logger
Logs the given message at debug level, with Throwable information.

Specified by:
debug in interface Logger
Parameters:
msg - the message to log
thrown - the Throwable to log

getLogger

public Logger getLogger(String name)
Specified by:
getLogger in interface Logger
Parameters:
name - the name of the logger
Returns:
a logger with the given name

toString

public String toString()
Overrides:
toString in class Object

ignore

public void ignore(Throwable ignored)
Description copied from interface: Logger
Ignore an exception.

This should be used rather than an empty catch block.

Specified by:
ignore in interface Logger


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.