|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.org.lidalia.sysoutslf4j.context.SysOutOverSLF4J
public final class SysOutOverSLF4J
Public interface to the sysout-over-slf4j module. Provides all methods necessary to manage wrapping the existing
System.out and System.err PrintStreams with
custom SLF4JPrintStreamImpls that redirect to a logging system
via SLF4J.
Synchronizes on System.class to ensure proper synchronization even if this class is loaded
by multiple classloaders.
SLF4JPrintStreamImpl| Method Summary | |
|---|---|
static boolean |
isInLoggingSystem(String className)
Checks whether the given fully qualified class name is a member of a package registered as being a logging system. |
static void |
registerLoggingSystem(String packageName)
Registers a package as being a logging system and hence any calls to System.out/err println from classes within it should be allowed through to the original PrintStreams rather than redirected to SLF4J. |
static void |
restoreOriginalSystemOutputs()
If System.out and System.err have been redirected to SLF4J, restores the original PrintStreams allowing direct access to the console again. This will stop all contexts in the JVM from using sysout-over-slf4j. |
static void |
sendSystemOutAndErrToSLF4J()
If they have not previously been wrapped, wraps the System.out and System.err PrintStreams in an SLF4JPrintStreamImpl and registers
SLF4J for the current context.Can be called any number of times, and is synchronized on System.class. Uses the LogPerLineExceptionHandlingStrategyFactory
for handling printlns coming from Throwable.printStackTrace().Logs at info level for System.out and at error level for System.err. |
static void |
sendSystemOutAndErrToSLF4J(ExceptionHandlingStrategyFactory exceptionHandlingStrategyFactory)
If they have not previously been wrapped, wraps the System.out and System.err PrintStreams in an SLF4JPrintStreamImpl and registers
SLF4J for the current context's classloader.Can be called any number of times, and is synchronized on System.class. |
static void |
sendSystemOutAndErrToSLF4J(LogLevel outLevel,
LogLevel errLevel)
If they have not previously been wrapped, wraps the System.out and System.err PrintStreams in an SLF4JPrintStreamImpl and registers
SLF4J for the current context's classloader.Can be called any number of times, and is synchronized on System.class. Uses the LogPerLineExceptionHandlingStrategy for handling printlns coming from Throwable.printStackTrace(). |
static void |
sendSystemOutAndErrToSLF4J(LogLevel outLevel,
LogLevel errLevel,
ExceptionHandlingStrategyFactory exceptionHandlingStrategyFactory)
If they have not previously been wrapped, wraps the System.out and System.err PrintStreams in an SLF4JPrintStreamImpl and registers
SLF4J for the current context's classloader.Can be called any number of times, and is synchronized on System.class. |
static void |
stopSendingSystemOutAndErrToSLF4J()
Stops using SLF4J for calls to System.out and System.err in the current context. |
static boolean |
systemOutputsAreSLF4JPrintStreams()
|
static void |
unregisterLoggingSystem(String packageName)
Unregisters a package as being a logging system and hence any calls to System.out/err println from classes within it will be redirected to SLF4J. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void sendSystemOutAndErrToSLF4J()
SLF4JPrintStreamImpl and registers
SLF4J for the current context.LogPerLineExceptionHandlingStrategyFactory
for handling printlns coming from Throwable.printStackTrace().
public static void sendSystemOutAndErrToSLF4J(LogLevel outLevel,
LogLevel errLevel)
SLF4JPrintStreamImpl and registers
SLF4J for the current context's classloader.
outLevel - The SLF4J LogLevel at which calls to System.out should be loggederrLevel - The SLF4J LogLevel at which calls to System.err should be loggedpublic static void sendSystemOutAndErrToSLF4J(ExceptionHandlingStrategyFactory exceptionHandlingStrategyFactory)
SLF4JPrintStreamImpl and registers
SLF4J for the current context's classloader.
exceptionHandlingStrategyFactory - The ExceptionHandlingStrategyFactory
for creating strategies for handling printlns coming from Throwable.printStackTrace()
public static void sendSystemOutAndErrToSLF4J(LogLevel outLevel,
LogLevel errLevel,
ExceptionHandlingStrategyFactory exceptionHandlingStrategyFactory)
SLF4JPrintStreamImpl and registers
SLF4J for the current context's classloader.
outLevel - The SLF4J LogLevel at which calls to System.out should be loggederrLevel - The SLF4J LogLevel at which calls to System.err should be loggedexceptionHandlingStrategyFactory - The ExceptionHandlingStrategyFactory
for creating strategies for handling printlns coming from Throwable.printStackTrace()public static void stopSendingSystemOutAndErrToSLF4J()
public static void restoreOriginalSystemOutputs()
stopSendingSystemOutAndErrToSLF4J() as well as this method.
Can be called any number of times, and is synchronized on System.class.
public static void registerLoggingSystem(String packageName)
packageName - A package name e.g. org.someloggingsystempublic static void unregisterLoggingSystem(String packageName)
packageName - A package name e.g. org.someloggingsystempublic static boolean isInLoggingSystem(String className)
className - The fully qualifed name of the class which may be in
a registered logging system
public static boolean systemOutputsAreSLF4JPrintStreams()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||