public class LoggerUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
LoggerUtils.LoggingOutputStream
An OutputStream that writes contents to a Logger upon each call to flush()
Original URL: https://blogs.oracle.com/nickstephen/entry/java_redirecting_system_out_and
Author gives permission for free use in blog comments section.
|
static class |
LoggerUtils.StdOutErrLevel
Class defining 2 new Logging levels, one for STDOUT, one for STDERR, used
when multiplexing STDOUT and STDERR into the same rolling log file via
the Java Logging APIs.
From: http://blogs.sun.com/nickstephen/entry/java_redirecting_system_out_and |
Constructor and Description |
---|
LoggerUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addTerseFileLogger(Level level,
String filename)
In cases where a logging.properties file is too cumbersome, sets terse
formatter for file handler.
|
void |
dumpAncestry(Logger logger)
Prints own and parents' log levels to standard out (for debugging).
|
static Level |
getLevelRecursive(Logger logger)
Traverses parents to find effective log level.
|
static Logger |
getLogger(Class<?> clazz)
Convenience wrapper around
Logger.getLogger(String) . |
static void |
initializeLogging()
Initialize Java logging to use "logging.properties" as the configuration
file and re-read the logging configuration from this file.
|
static void |
initializeLogging(String configurationFilename)
Initialize Java logging to use given configuration file and re-read the
logging configuration from this file.
|
static void |
initializeLogging(String configurationFilename,
StreamOpener streamOpener)
Initialize Java logging to use given configuration file and re-read the
logging configuration from this file.
|
static void |
log(Logger logger,
Level level,
String format,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
log(Logger logger,
Level level,
String format,
Throwable thrown,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logConfig(Logger logger,
String format,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logConfig(Logger logger,
String format,
Throwable thrown,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logFine(Logger logger,
String format,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logFine(Logger logger,
String format,
Throwable thrown,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logFiner(Logger logger,
String format,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logFiner(Logger logger,
String format,
Throwable thrown,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logFinest(Logger logger,
String format,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logFinest(Logger logger,
String format,
Throwable thrown,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logInfo(Logger logger,
String format,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logInfo(Logger logger,
String format,
Throwable thrown,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logSevere(Logger logger,
String format,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logSevere(Logger logger,
String format,
Throwable thrown,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logWarning(Logger logger,
String format,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
logWarning(Logger logger,
String format,
Throwable thrown,
Object... args)
Wraps call to Java logger with varargs and performance optimization: no argument formatting
if unneeded.
|
static void |
sendStderrToLog() |
static void |
sendStdoutToLog() |
static void |
setLoggerLevel(Level level) |
static void |
setTerseConsoleLogger(Level level)
In cases where a logging.properties file is too cumbersome, sets terse
formatter for console handler.
|
public static Logger getLogger(Class<?> clazz)
Logger.getLogger(String)
. Uses
the fully qualified classname of the specified class as the logger
name.public static Level getLevelRecursive(Logger logger)
public void dumpAncestry(Logger logger)
public static void initializeLogging()
Note: Similar to setting -Djava.util.logging.config.file=logging.properties on java command line.
public static void initializeLogging(String configurationFilename)
Note: Similar to setting -Djava.util.logging.config.file=configurationFilename on java command line.
public static void initializeLogging(String configurationFilename, StreamOpener streamOpener)
Note: Similar to setting -Djava.util.logging.config.file=configurationFilename on java command line.
public static final void setTerseConsoleLogger(Level level)
level
- maximum logging level; set on root loggerpublic static final void addTerseFileLogger(Level level, String filename) throws SecurityException, IOException
level
- maximum logging level; set on root loggerIOException
SecurityException
public static final void setLoggerLevel(Level level)
public static void sendStdoutToLog()
public static void sendStderrToLog()
public static void log(Logger logger, Level level, String format, Object... args)
public static void logFinest(Logger logger, String format, Object... args)
public static void logFiner(Logger logger, String format, Object... args)
public static void logFine(Logger logger, String format, Object... args)
public static void logConfig(Logger logger, String format, Object... args)
public static void logInfo(Logger logger, String format, Object... args)
public static void logWarning(Logger logger, String format, Object... args)
public static void logSevere(Logger logger, String format, Object... args)
public static void log(Logger logger, Level level, String format, Throwable thrown, Object... args)
public static void logFinest(Logger logger, String format, Throwable thrown, Object... args)
public static void logFiner(Logger logger, String format, Throwable thrown, Object... args)
public static void logFine(Logger logger, String format, Throwable thrown, Object... args)
public static void logConfig(Logger logger, String format, Throwable thrown, Object... args)
public static void logInfo(Logger logger, String format, Throwable thrown, Object... args)
public static void logWarning(Logger logger, String format, Throwable thrown, Object... args)
Copyright © 2016 Metron, Inc.. All rights reserved.