Package com.gengoai
Class LogUtils
- java.lang.Object
-
- com.gengoai.LogUtils
-
public final class LogUtils extends Object
Utilities for working with java.util.Logger.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addFileHandler(String basename)
Adds a file handler that writes to the location specified incom.gengoai.logging.dir
or if not setUSER_HOME/logs/
.static void
addHandler(Handler handler)
Adds a handler to the root.static Logger
getGlobalLogger()
Gets the global Loggerstatic Logger
getLogger(@NonNull Class<?> clazz)
Gets a logger for the given class..static Logger
getRootLogger()
Gets the root logger.static void
log(@NonNull Logger logger, @NonNull Level level, @NonNull Throwable throwable)
Logs the given throwable at a given level.static void
log(@NonNull Logger logger, @NonNull Level level, String message, @NonNull Throwable throwable)
Logs a message at a given level.static void
log(@NonNull Logger logger, @NonNull Level level, String message, Object... params)
Logs a message at a given level.static void
logConfig(@NonNull Logger logger, @NonNull Throwable throwable)
Logs the given throwable atLevel.CONFIG
.static void
logConfig(@NonNull Logger logger, String message, @NonNull Throwable throwable)
Logs the given throwable atLevel.CONFIG
.static void
logConfig(@NonNull Logger logger, String message, Object... params)
Logs a message atLevel.CONFIG
.static void
logFine(@NonNull Logger logger, @NonNull Throwable throwable)
Logs the given throwable atLevel.FINE
.static void
logFine(@NonNull Logger logger, String message, @NonNull Throwable throwable)
Logs the given throwable atLevel.FINE
.static void
logFine(@NonNull Logger logger, String message, Object... params)
Logs a message atLevel.FINE
.static void
logFiner(@NonNull Logger logger, @NonNull Throwable throwable)
Logs the given throwable atLevel.FINER
.static void
logFiner(@NonNull Logger logger, String message, @NonNull Throwable throwable)
Logs the given throwable atLevel.FINER
.static void
logFiner(@NonNull Logger logger, String message, Object... params)
Logs a message atLevel.FINER
.static void
logFinest(@NonNull Logger logger, @NonNull Throwable throwable)
Logs the given throwable atLevel.FINEST
.static void
logFinest(@NonNull Logger logger, String message, @NonNull Throwable throwable)
Logs the given throwable atLevel.FINEST
.static void
logFinest(@NonNull Logger logger, String message, Object... params)
Logs a message atLevel.FINEST
.static void
logInfo(@NonNull Logger logger, @NonNull Throwable throwable)
Logs the given throwable atLevel.INFO
.static void
logInfo(@NonNull Logger logger, String message, @NonNull Throwable throwable)
Logs the given throwable atLevel.INFO
.static void
logInfo(@NonNull Logger logger, String message, Object... params)
Logs a message atLevel.INFO
.static void
logSevere(@NonNull Logger logger, @NonNull Throwable throwable)
Logs the given throwable atLevel.SEVERE
.static void
logSevere(@NonNull Logger logger, String message, @NonNull Throwable throwable)
Logs the given throwable atLevel.SEVERE
.static void
logSevere(@NonNull Logger logger, String message, Object... params)
Logs a message atLevel.SEVERE
.static void
logWarning(@NonNull Logger logger, @NonNull Throwable throwable)
Logs the given throwable atLevel.WARNING
.static void
logWarning(@NonNull Logger logger, String message, @NonNull Throwable throwable)
Logs the given throwable atLevel.WARNING
.static void
logWarning(@NonNull Logger logger, String message, Object... params)
Logs a message atLevel.WARNING
.static void
setLevel(String logger, Level level)
Sets the level of a logger
-
-
-
Method Detail
-
addFileHandler
public static void addFileHandler(String basename) throws IOException
Adds a file handler that writes to the location specified incom.gengoai.logging.dir
or if not setUSER_HOME/logs/
. The filenames are in the form ofbasename%g
where %g is the rotated file number. Max file size is 100MB and 50 files will be used.- Parameters:
basename
- the basename- Throws:
IOException
- the io exception
-
addHandler
public static void addHandler(Handler handler)
Adds a handler to the root.- Parameters:
handler
- the handler to add
-
getGlobalLogger
public static Logger getGlobalLogger()
Gets the global Logger- Returns:
- The global logger
-
getLogger
public static Logger getLogger(@NonNull @NonNull Class<?> clazz)
Gets a logger for the given class..- Parameters:
clazz
- the class whose name will become the logger name- Returns:
- the logger
-
getRootLogger
public static Logger getRootLogger()
Gets the root logger.- Returns:
- the root logger
-
log
public static void log(@NonNull @NonNull Logger logger, @NonNull @NonNull Level level, String message, Object... params)
Logs a message at a given level.- Parameters:
logger
- the loggerlevel
- The level to log the message at.message
- The message accompanying the logparams
- The arguments for the message.
-
log
public static void log(@NonNull @NonNull Logger logger, @NonNull @NonNull Level level, @NonNull @NonNull Throwable throwable)
Logs the given throwable at a given level.- Parameters:
logger
- the loggerlevel
- The level to log the message at.throwable
- The throwable for the message.
-
log
public static void log(@NonNull @NonNull Logger logger, @NonNull @NonNull Level level, String message, @NonNull @NonNull Throwable throwable)
Logs a message at a given level.- Parameters:
logger
- the loggerlevel
- The level to log the message at.message
- The message accompanying the logthrowable
- The throwable for the message.
-
logConfig
public static void logConfig(@NonNull @NonNull Logger logger, String message, Object... params)
Logs a message atLevel.CONFIG
.- Parameters:
logger
- the loggermessage
- The message accompanying the logparams
- The arguments for the message.
-
logConfig
public static void logConfig(@NonNull @NonNull Logger logger, String message, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.CONFIG
.- Parameters:
logger
- the loggermessage
- The message accompanying the logthrowable
- The throwable to log.
-
logConfig
public static void logConfig(@NonNull @NonNull Logger logger, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.CONFIG
.- Parameters:
logger
- the loggerthrowable
- The throwable to log.
-
logFine
public static void logFine(@NonNull @NonNull Logger logger, String message, Object... params)
Logs a message atLevel.FINE
.- Parameters:
logger
- the loggermessage
- The message accompanying the logparams
- The arguments for the message.
-
logFine
public static void logFine(@NonNull @NonNull Logger logger, String message, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.FINE
.- Parameters:
logger
- the loggermessage
- The message accompanying the logthrowable
- The throwable to log.
-
logFine
public static void logFine(@NonNull @NonNull Logger logger, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.FINE
.- Parameters:
logger
- the loggerthrowable
- The throwable to log.
-
logFiner
public static void logFiner(@NonNull @NonNull Logger logger, String message, Object... params)
Logs a message atLevel.FINER
.- Parameters:
logger
- the loggermessage
- The message accompanying the logparams
- The arguments for the message.
-
logFiner
public static void logFiner(@NonNull @NonNull Logger logger, String message, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.FINER
.- Parameters:
logger
- the loggermessage
- The message accompanying the logthrowable
- The throwable to log.
-
logFiner
public static void logFiner(@NonNull @NonNull Logger logger, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.FINER
.- Parameters:
logger
- the loggerthrowable
- The throwable to log.
-
logFinest
public static void logFinest(@NonNull @NonNull Logger logger, String message, Object... params)
Logs a message atLevel.FINEST
.- Parameters:
logger
- the loggermessage
- The message accompanying the logparams
- The arguments for the message.
-
logFinest
public static void logFinest(@NonNull @NonNull Logger logger, String message, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.FINEST
.- Parameters:
logger
- the loggermessage
- The message accompanying the logthrowable
- The throwable to log.
-
logFinest
public static void logFinest(@NonNull @NonNull Logger logger, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.FINEST
.- Parameters:
logger
- the loggerthrowable
- The throwable to log.
-
logInfo
public static void logInfo(@NonNull @NonNull Logger logger, String message, Object... params)
Logs a message atLevel.INFO
.- Parameters:
logger
- the loggermessage
- The message accompanying the logparams
- The arguments for the message.
-
logInfo
public static void logInfo(@NonNull @NonNull Logger logger, String message, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.INFO
.- Parameters:
logger
- the loggermessage
- The message accompanying the logthrowable
- The throwable to log.
-
logInfo
public static void logInfo(@NonNull @NonNull Logger logger, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.INFO
.- Parameters:
logger
- the loggerthrowable
- The throwable to log.
-
logSevere
public static void logSevere(@NonNull @NonNull Logger logger, String message, Object... params)
Logs a message atLevel.SEVERE
.- Parameters:
logger
- the loggermessage
- The message accompanying the logparams
- The arguments for the message.
-
logSevere
public static void logSevere(@NonNull @NonNull Logger logger, String message, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.SEVERE
.- Parameters:
logger
- the loggermessage
- The message accompanying the logthrowable
- The throwable to log.
-
logSevere
public static void logSevere(@NonNull @NonNull Logger logger, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.SEVERE
.- Parameters:
logger
- the loggerthrowable
- The throwable to log.
-
logWarning
public static void logWarning(@NonNull @NonNull Logger logger, String message, Object... params)
Logs a message atLevel.WARNING
.- Parameters:
logger
- the loggermessage
- The message accompanying the logparams
- The arguments for the message.
-
logWarning
public static void logWarning(@NonNull @NonNull Logger logger, String message, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.WARNING
.- Parameters:
logger
- the loggermessage
- The message accompanying the logthrowable
- The throwable to log.
-
logWarning
public static void logWarning(@NonNull @NonNull Logger logger, @NonNull @NonNull Throwable throwable)
Logs the given throwable atLevel.WARNING
.- Parameters:
logger
- the loggerthrowable
- The throwable to log.
-
-