Class PlatformLogger
java.lang.Object
org.apache.log4j.Category
org.apache.log4j.Logger
com.onenetwork.platform.tools.log.PlatformLogger
public class PlatformLogger
extends org.apache.log4j.Logger
Platform logger (based on log4j) which adds convenience methods for additional log levels
introduced by
PlatformLevel
.
Typical usage is to statically initialize a logger in your class and use it throughout. For example:
public class MyClass { private static final PlatformLogger LOG = PlatformLogger.get(MyClass.class); public void myMethod() { LOG.debugMedium("This is a medium level debug log"); } }
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PlatformLogger(java.lang.String name)
Deprecated.not for direct use by clients; useget(Class)
-
Method Summary
Modifier and Type Method Description void
debug(java.util.function.Supplier<?> s)
Executes the given Supplier function and logs the result iffLevel.DEBUG
is enabled.void
debug(java.util.function.Supplier<?> s, java.lang.Throwable t)
Executes the given Supplier function and logs the result iffLevel.DEBUG
is enabled.void
debugDetailed(java.lang.Object message)
Log this message atPlatformLevel.DEBUG_DETAILED
void
debugDetailed(java.lang.Object message, java.lang.Throwable t)
Log this message and throwable atPlatformLevel.DEBUG_DETAILED
void
debugDetailed(java.util.function.Supplier<?> s)
Executes the given Supplier function and logs the result iffPlatformLevel.DEBUG_DETAILED
is enabled.void
debugMedium(java.lang.Object message)
Log this message atPlatformLevel.DEBUG_MEDIUM
void
debugMedium(java.lang.Object message, java.lang.Throwable t)
Log this message and throwable atPlatformLevel.DEBUG_MEDIUM
void
debugMedium(java.util.function.Supplier<?> s)
Executes the given Supplier function and logs the result iffPlatformLevel.DEBUG_MEDIUM
is enabled.void
debugSql(java.lang.Object message)
Log this message atPlatformLevel.DEBUG_SQL
void
debugSql(java.lang.Object message, java.lang.Throwable t)
Log this message and throwable atPlatformLevel.DEBUG_SQL
void
debugSql(java.util.function.Supplier<?> s)
Executes the given Supplier function and logs the result iffPlatformLevel.DEBUG_SQL
is enabled.void
forcedLog(java.lang.String fqcn, org.apache.log4j.Priority plevel, java.lang.Object message, java.lang.Throwable t)
Deprecated.not for use by clientsstatic PlatformLogger
get(java.lang.Class<?> clazz)
Preferred method for clients to acquire Logger instances.static PlatformLogger
get(java.lang.String name)
Returns a suitable logger for the given fully-qualified class or package namestatic org.apache.log4j.Category
getInstance(java.lang.Class aclass)
Deprecated.not for direct use by clients; useget(Class)
static org.apache.log4j.Category
getInstance(java.lang.String name)
Deprecated.not for direct use by clients; useget(Class)
static org.apache.log4j.Logger
getLogger(java.lang.Class aclass)
Deprecated.not for direct use by clients; useget(Class)
static org.apache.log4j.Logger
getLogger(java.lang.String name)
Deprecated.not for direct use by clients; useget(Class)
boolean
isDebugDetailedEnabled()
boolean
isDebugEnabled()
boolean
isDebugMediumEnabled()
boolean
isDebugSqlEnabled()
void
log(java.lang.Object message, java.lang.Throwable t, org.apache.log4j.Level lvl)
Log the given message and throwable at the given levelvoid
log(java.lang.Object message, org.apache.log4j.Level lvl)
Log the given message at the given levelMethods inherited from class org.apache.log4j.Category
addAppender, assertLog, callAppenders, debug, debug, error, error, exists, fatal, fatal, getAdditivity, getAllAppenders, getAppender, getChainedPriority, getCurrentCategories, getEffectiveLevel, getLevel, getName, getParent, getPriority, getResourceBundle, getRoot, info, info, isAttached, isEnabledFor, isErrorEnabled, isFatalEnabled, isInfoEnabled, isTraceEnabled, isWarnEnabled, l7dlog, l7dlog, log, log, log, removeAllAppenders, removeAppender, removeAppender, setAdditivity, setLevel, setPriority, setResourceBundle, shutdown, trace, trace, warn, warn
-
Constructor Details
-
PlatformLogger
public PlatformLogger(java.lang.String name)Deprecated.not for direct use by clients; useget(Class)
-
-
Method Details
-
get
Preferred method for clients to acquire Logger instances.- Parameters:
clazz
- class which is performing the logging- Returns:
- suitable logger for that class
-
get
Returns a suitable logger for the given fully-qualified class or package name- Parameters:
class
- or package name of logger- Returns:
- suitable logger for that class or package
-
getInstance
public static org.apache.log4j.Category getInstance(java.lang.String name)Deprecated.not for direct use by clients; useget(Class)
- See Also:
Category.getInstance(String)
-
getLogger
public static org.apache.log4j.Logger getLogger(java.lang.String name)Deprecated.not for direct use by clients; useget(Class)
- See Also:
Logger.getLogger(String)
-
getLogger
public static org.apache.log4j.Logger getLogger(java.lang.Class aclass)Deprecated.not for direct use by clients; useget(Class)
- See Also:
Logger.getLogger(Class)
-
getInstance
public static org.apache.log4j.Category getInstance(java.lang.Class aclass)Deprecated.not for direct use by clients; useget(Class)
- See Also:
Category.getInstance(java.lang.String)
-
isDebugEnabled
public boolean isDebugEnabled()- Overrides:
isDebugEnabled
in classorg.apache.log4j.Category
- Returns:
- true if level is
PlatformLevel.DEBUG_SQL
or below - See Also:
Category.isDebugEnabled()
-
debug
public void debug(java.util.function.Supplier<?> s)Executes the given Supplier function and logs the result iffLevel.DEBUG
is enabled. If DEBUG is not enabled, exits quietly without evaluating the function. Meant to be used as a lambda, for example:LOG.debug(() -> "Found " + count + " records");
This pattern prevents the client from having to call isDebugEnabled() to avoid the cost of concatenation, i.e. it is shorter and more convenient than the following pattern:if (LOG.isDebugEnabled()) { LOG.debug("Found " + count + " records"); }
- Parameters:
s
- supplier function to execute
-
debug
public void debug(java.util.function.Supplier<?> s, java.lang.Throwable t)Executes the given Supplier function and logs the result iffLevel.DEBUG
is enabled. If DEBUG is not enabled, exits quietly without evaluating the function. Meant to be used as a lambda, for example:LOG.debug(() -> "Found " + count + " records", e);
This pattern prevents the client from having to call isDebugEnabled() to avoid the cost of concatenation, i.e. it is shorter and more convenient than the following pattern:if (LOG.isDebugEnabled()) { LOG.debug("Found " + count + " records"); }
- Parameters:
s
- supplier function to execute
-
isDebugDetailedEnabled
public boolean isDebugDetailedEnabled() -
isDebugMediumEnabled
public boolean isDebugMediumEnabled() -
isDebugSqlEnabled
public boolean isDebugSqlEnabled() -
debugSql
public void debugSql(java.lang.Object message)Log this message atPlatformLevel.DEBUG_SQL
- Parameters:
message
- message to log
-
debugSql
public void debugSql(java.lang.Object message, java.lang.Throwable t)Log this message and throwable atPlatformLevel.DEBUG_SQL
- Parameters:
message
- message to logt
- root cause
-
debugSql
public void debugSql(java.util.function.Supplier<?> s)Executes the given Supplier function and logs the result iffPlatformLevel.DEBUG_SQL
is enabled. If DEBUG_SQL is not enabled, exits quietly without evaluating the function. Meant to be used as a lambda, for example:LOG.debugSql(() -> "Found " + count + " records");
This pattern prevents the client from having to call isDebugSqlEnabled() to avoid the cost of concatenation, i.e. it is shorter and more convenient than the following pattern:if (LOG.isDebugSqlEnabled()) { LOG.debugSql("Found " + count + " records"); }
- Parameters:
s
- supplier function to execute
-
debugMedium
public void debugMedium(java.lang.Object message)Log this message atPlatformLevel.DEBUG_MEDIUM
- Parameters:
message
- message to log
-
debugMedium
public void debugMedium(java.lang.Object message, java.lang.Throwable t)Log this message and throwable atPlatformLevel.DEBUG_MEDIUM
- Parameters:
message
- message to logt
- root cause
-
debugMedium
public void debugMedium(java.util.function.Supplier<?> s)Executes the given Supplier function and logs the result iffPlatformLevel.DEBUG_MEDIUM
is enabled. If DEBUG_MEDIUM is not enabled, exits quietly without evaluating the function. Meant to be used as a lambda, for example:LOG.debugMedium(() -> "Found " + count + " records");
This pattern prevents the client from having to call isDebugMediumEnabled() to avoid the cost of concatenation, i.e. it is shorter and more convenient than the following pattern:if (LOG.isDebugMediumEnabled()) { LOG.debugMedium("Found " + count + " records"); }
- Parameters:
s
- supplier function to execute
-
debugDetailed
public void debugDetailed(java.lang.Object message)Log this message atPlatformLevel.DEBUG_DETAILED
- Parameters:
message
- message to log
-
debugDetailed
public void debugDetailed(java.lang.Object message, java.lang.Throwable t)Log this message and throwable atPlatformLevel.DEBUG_DETAILED
- Parameters:
message
- message to logt
- root cause
-
debugDetailed
public void debugDetailed(java.util.function.Supplier<?> s)Executes the given Supplier function and logs the result iffPlatformLevel.DEBUG_DETAILED
is enabled. If DEBUG_DETAILED is not enabled, exits quietly without evaluating the function. Meant to be used as a lambda, for example:LOG.debugDetailed(() -> "Found " + count + " records");
This pattern prevents the client from having to call isDebugDetailedEnabled() to avoid the cost of concatenation, i.e. it is shorter and more convenient than the following pattern:if (LOG.isDebugDetailedEnabled()) { LOG.debugDetailed("Found " + count + " records"); }
- Parameters:
s
- supplier function to execute
-
log
public void log(java.lang.Object message, org.apache.log4j.Level lvl)Log the given message at the given level- Parameters:
message
- The message to loglvl
- level at which to log the exception
-
log
public void log(java.lang.Object message, java.lang.Throwable t, org.apache.log4j.Level lvl)Log the given message and throwable at the given level- Parameters:
message
- The message to loglvl
- level at which to log the exceptiont
- root cause
-
forcedLog
public void forcedLog(java.lang.String fqcn, org.apache.log4j.Priority plevel, java.lang.Object message, java.lang.Throwable t)Deprecated.not for use by clients- Overrides:
forcedLog
in classorg.apache.log4j.Category
-