public class LambdaLogger
extends org.apache.log4j.Logger
log.debug(() -> getMessage()); // getMessage() only called if log level >= DEBUG
In this example getMessage() will not be called unless the log level is
set to DEBUG or higher. Conditional logging drastically improves
performance and should ALWAYS be preferred in production (non-test) code
over the unconditional logging syntax:
log.debug(getMessage()); // getMessage() called regardless of log levelModifier and Type | Class and Description |
---|---|
static interface |
LambdaLogger.Supplier<T>
Checked exception throwing version of
Supplier<T> . |
Modifier and Type | Method and Description |
---|---|
void |
debug(LambdaLogger.Supplier<Object> supplier)
Conditionally log at DEBUG.
|
static LambdaLogger |
getLogger(Class c)
Override to return a LambdaLogger.
|
static LambdaLogger |
getLogger(String name)
Override to return a LambdaLogger.
|
void |
info(LambdaLogger.Supplier<Object> supplier)
Conditionally log at INFO.
|
protected void |
log(org.apache.log4j.Level level,
LambdaLogger.Supplier<Object> supplier)
Conditionally log at the specified level.
|
static void |
quiet(Class<?> cls,
Code code)
Run the supplied code, quieting the supplied log at Level.ERROR
|
static void |
quiet(Class<?> cls,
org.apache.log4j.Level set,
Code code)
Run the supplied code, quieting the supplied log with the specified Level
|
void |
trace(LambdaLogger.Supplier<Object> supplier)
Conditionally log at TRACE.
|
getLogger, getRootLogger, isTraceEnabled, trace, trace
addAppender, assertLog, callAppenders, debug, debug, error, error, exists, fatal, fatal, forcedLog, getAdditivity, getAllAppenders, getAppender, getChainedPriority, getCurrentCategories, getDefaultHierarchy, getEffectiveLevel, getHierarchy, getInstance, getInstance, getLevel, getLoggerRepository, getName, getParent, getPriority, getResourceBundle, getResourceBundleString, getRoot, info, info, isAttached, isDebugEnabled, isEnabledFor, isInfoEnabled, l7dlog, l7dlog, log, log, log, removeAllAppenders, removeAppender, removeAppender, setAdditivity, setLevel, setPriority, setResourceBundle, shutdown, warn, warn
public static final void quiet(Class<?> cls, Code code) throws Exception
Exception
public static final void quiet(Class<?> cls, org.apache.log4j.Level set, Code code) throws Exception
Exception
public static LambdaLogger getLogger(String name)
public static LambdaLogger getLogger(Class c)
protected void log(org.apache.log4j.Level level, LambdaLogger.Supplier<Object> supplier)
supplier.get()
unless log.getLevel() >= level
(conditional message production).
If the supplied object is a stream, conditionally log each object in
the stream on a separate line.public void info(LambdaLogger.Supplier<Object> supplier)
public void debug(LambdaLogger.Supplier<Object> supplier)
public void trace(LambdaLogger.Supplier<Object> supplier)
Copyright © 2015–2016 SYSTAP, LLC DBA Blazegraph. All rights reserved.