Class LoggerEx
- java.lang.Object
- 
- com.inductiveautomation.ignition.common.util.LoggerEx
 
- 
- Direct Known Subclasses:
- ReportExecutionContext.ReportLoggerEx
 
 public class LoggerEx extends java.lang.ObjectThis class is a wrapper around a logger which provides additional useful tools. To create one, use the newBuilder() function and configure the builder.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classLoggerEx.Builderprotected classLoggerEx.DurationTrackerprotected classLoggerEx.InternalMDCClosableprotected static classLoggerEx.Levelstatic classLoggerEx.MDCClosable
 - 
Field SummaryFields Modifier and Type Field Description static org.apache.commons.lang3.builder.ToStringStyleDEFAULT_TO_STRING_STYLEprotected org.slf4j.MarkereventMarkerprotected java.lang.ObjectidentObjThe ident object to tack onto the beginning of all log messages (may be null).protected booleanidentObjectIsMutableSet this to true if you want the ident object to be to-stringed for each log messageprotected java.lang.StringidentObjStrThe stored toString of the ident object (may be null)protected org.slf4j.LoggerlogThe underlying loggerprotected java.lang.Object[]mdcContextKVprotected org.apache.commons.lang3.builder.ToStringStyletoStringStyleThe style to use to turn the ident obj into a string
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected java.lang.StringcreateMessage(java.lang.String message, java.lang.Object... args)LoggerExcreateSubLogger(java.lang.Class<?> clazz)LoggerExcreateSubLogger(java.lang.String name)Creates a child logger that extends from the current name, with the same identity object, event marker, and MDC context.voiddebug(java.lang.String message)voiddebug(java.lang.String message, java.lang.Throwable t)java.io.CloseabledebugDuration(java.lang.String message)Duration trackers log start and finish times for operations.voiddebugEvent(java.lang.String message, java.lang.Object... args)Logs a debug message with the event marker defined on the logger.voiddebugf(java.lang.String message, java.lang.Object... args)voiddebugf(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)voiderror(java.lang.String message)voiderror(java.lang.String message, java.lang.Throwable t)voiderrorEvent(java.lang.String message, java.lang.Object... args)Logs an error message with the event marker defined on the logger.voiderrorf(java.lang.String message, java.lang.Object... args)voiderrorf(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)voidfatal(java.lang.String message)voidfatal(java.lang.String message, java.lang.Throwable t)protected java.lang.StringgenerateIdentObjStr()java.lang.ObjectgetIdentObject()org.apache.log4j.LoggergetLogger()Deprecated.org.slf4j.LoggergetLoggerSLF4J()java.lang.StringgetName()org.apache.commons.lang3.builder.ToStringStylegetToStringStyle()voidinfo(java.lang.String message)voidinfo(java.lang.String message, java.lang.Throwable t)java.io.CloseableinfoDuration(java.lang.String message)Duration trackers log start and finish times for operations.voidinfoEvent(java.lang.String message, java.lang.Object... args)Logs an info message with the event marker defined on the logger.voidinfof(java.lang.String message, java.lang.Object... args)voidinfof(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)booleanisDebugEnabled()booleanisIdentObjectIsMutable()booleanisInfoEnabled()booleanisTraceEnabled()static voidlog(java.lang.Class<?> clazz, LoggerEx.Level level, MDCUtils.MDCDetails mdc, java.lang.String message, java.lang.Object... args)Deprecated.voidmdcClose()The complementary function to mdcSet, if the AutoClosable return of the set function wasn't used.voidmdcPut(java.lang.String key, java.lang.String value)Convenience function that calls MDC putLoggerEx.MDCClosablemdcPutClosable(java.lang.String key, java.lang.String value)voidmdcRemove(java.lang.String key)Convenience function that calls MDC removeLoggerEx.MDCClosablemdcSet()Sets the registered mdc key/value pairs and returns a closable that can be used to unset them.static LoggerEx.BuildernewBuilder()protected voidsetEventMarker(org.slf4j.Marker marker)voidsetIdentObject(java.lang.Object identObj)voidsetIdentObjectIsMutable(boolean identObjectIsMutable)protected voidsetLog(org.slf4j.Logger log)protected voidsetStaticMDCContextValues(java.lang.Object... values)A set of key/value pairs that will be set and unset in the mdc context around each logging operation.voidsetToStringStyle(org.apache.commons.lang3.builder.ToStringStyle toStringStyle)voidtrace(java.lang.String message)voidtrace(java.lang.String message, java.lang.Throwable t)java.io.CloseabletraceDuration(java.lang.String message)Duration trackers log start and finish times for operations.voidtraceEvent(java.lang.String message, java.lang.Object... args)Logs a trace message with the event marker defined on the logger.voidtracef(java.lang.String message, java.lang.Object... args)voidtracef(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)voidwarn(java.lang.String message)voidwarn(java.lang.String message, java.lang.Throwable t)voidwarnEvent(java.lang.String message, java.lang.Object... args)Logs a warning message with the event marker defined on the logger.voidwarnf(java.lang.String message, java.lang.Object... args)voidwarnf(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)
 
- 
- 
- 
Field Detail- 
logprotected org.slf4j.Logger log The underlying logger
 - 
toStringStyleprotected org.apache.commons.lang3.builder.ToStringStyle toStringStyle The style to use to turn the ident obj into a string
 - 
identObjprotected java.lang.Object identObj The ident object to tack onto the beginning of all log messages (may be null).
 - 
identObjStrprotected java.lang.String identObjStr The stored toString of the ident object (may be null)
 - 
identObjectIsMutableprotected boolean identObjectIsMutable Set this to true if you want the ident object to be to-stringed for each log message
 - 
eventMarkerprotected org.slf4j.Marker eventMarker 
 - 
mdcContextKVprotected java.lang.Object[] mdcContextKV 
 - 
DEFAULT_TO_STRING_STYLEpublic static final org.apache.commons.lang3.builder.ToStringStyle DEFAULT_TO_STRING_STYLE 
 
- 
 - 
Constructor Detail- 
LoggerEx@Deprecated public LoggerEx(org.apache.log4j.Logger subLogger) Deprecated.Should be replaced with calls to the builder
 - 
LoggerEx@Deprecated public LoggerEx(org.apache.log4j.Logger subLogger, java.lang.Object identObj)Deprecated.Should be replaced by using the builder.
 
- 
 - 
Method Detail- 
newBuilderpublic static LoggerEx.Builder newBuilder() 
 - 
getNamepublic java.lang.String getName() 
 - 
createSubLoggerpublic LoggerEx createSubLogger(java.lang.Class<?> clazz) 
 - 
createSubLoggerpublic LoggerEx createSubLogger(java.lang.String name) Creates a child logger that extends from the current name, with the same identity object, event marker, and MDC context.
 - 
setStaticMDCContextValuesprotected void setStaticMDCContextValues(java.lang.Object... values) A set of key/value pairs that will be set and unset in the mdc context around each logging operation. The values can change their toString value, but the keys should not.
 - 
setEventMarkerprotected void setEventMarker(org.slf4j.Marker marker) 
 - 
setIdentObjectpublic void setIdentObject(java.lang.Object identObj) 
 - 
getIdentObjectpublic java.lang.Object getIdentObject() 
 - 
generateIdentObjStrprotected java.lang.String generateIdentObjStr() 
 - 
setToStringStylepublic void setToStringStyle(org.apache.commons.lang3.builder.ToStringStyle toStringStyle) 
 - 
getToStringStylepublic org.apache.commons.lang3.builder.ToStringStyle getToStringStyle() 
 - 
setIdentObjectIsMutablepublic void setIdentObjectIsMutable(boolean identObjectIsMutable) 
 - 
isIdentObjectIsMutablepublic boolean isIdentObjectIsMutable() 
 - 
createMessageprotected java.lang.String createMessage(java.lang.String message, java.lang.Object... args)
 - 
getLogger@Deprecated public org.apache.log4j.Logger getLogger() Deprecated.Returns a Log4j logger. Calls to this function should be eliminated.
 - 
getLoggerSLF4Jpublic org.slf4j.Logger getLoggerSLF4J() 
 - 
setLogprotected void setLog(org.slf4j.Logger log) 
 - 
tracefpublic void tracef(java.lang.String message, java.lang.Object... args)
 - 
tracefpublic void tracef(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)
 - 
debugfpublic void debugf(java.lang.String message, java.lang.Object... args)
 - 
debugfpublic void debugf(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)
 - 
infofpublic void infof(java.lang.String message, java.lang.Object... args)
 - 
infofpublic void infof(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)
 - 
warnfpublic void warnf(java.lang.String message, java.lang.Object... args)
 - 
warnfpublic void warnf(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)
 - 
errorfpublic void errorf(java.lang.String message, java.lang.Object... args)
 - 
errorfpublic void errorf(java.lang.String message, java.lang.Object[] args, java.lang.Throwable t)
 - 
traceEventpublic void traceEvent(java.lang.String message, java.lang.Object... args)Logs a trace message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
 - 
debugEventpublic void debugEvent(java.lang.String message, java.lang.Object... args)Logs a debug message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
 - 
infoEventpublic void infoEvent(java.lang.String message, java.lang.Object... args)Logs an info message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
 - 
warnEventpublic void warnEvent(java.lang.String message, java.lang.Object... args)Logs a warning message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
 - 
errorEventpublic void errorEvent(java.lang.String message, java.lang.Object... args)Logs an error message with the event marker defined on the logger. See Builder.eventSystem for more information about what events are.
 - 
log@Deprecated public static void log(java.lang.Class<?> clazz, LoggerEx.Level level, MDCUtils.MDCDetails mdc, java.lang.String message, java.lang.Object... args)Deprecated.This doesn't do anything useful and should not be used.
 - 
mdcPutpublic void mdcPut(java.lang.String key, java.lang.String value)Convenience function that calls MDC put
 - 
mdcRemovepublic void mdcRemove(java.lang.String key) Convenience function that calls MDC remove
 - 
mdcPutClosablepublic LoggerEx.MDCClosable mdcPutClosable(java.lang.String key, java.lang.String value) 
 - 
traceDurationpublic java.io.Closeable traceDuration(java.lang.String message) Duration trackers log start and finish times for operations. They return a closable and should be used in the try-with-resources style.- Parameters:
- message- and identifying message for the operation. Will be used for the start and end messages.
 
 - 
debugDurationpublic java.io.Closeable debugDuration(java.lang.String message) Duration trackers log start and finish times for operations. They return a closable and should be used in the try-with-resources style.- Parameters:
- message- and identifying message for the operation. Will be used for the start and end messages.
 
 - 
infoDurationpublic java.io.Closeable infoDuration(java.lang.String message) Duration trackers log start and finish times for operations. They return a closable and should be used in the try-with-resources style.- Parameters:
- message- and identifying message for the operation. Will be used for the start and end messages.
 
 - 
tracepublic void trace(java.lang.String message) 
 - 
tracepublic void trace(java.lang.String message, java.lang.Throwable t)
 - 
debugpublic void debug(java.lang.String message) 
 - 
debugpublic void debug(java.lang.String message, java.lang.Throwable t)
 - 
errorpublic void error(java.lang.String message) 
 - 
errorpublic void error(java.lang.String message, java.lang.Throwable t)
 - 
fatalpublic void fatal(java.lang.String message) 
 - 
fatalpublic void fatal(java.lang.String message, java.lang.Throwable t)
 - 
infopublic void info(java.lang.String message) 
 - 
infopublic void info(java.lang.String message, java.lang.Throwable t)
 - 
warnpublic void warn(java.lang.String message) 
 - 
warnpublic void warn(java.lang.String message, java.lang.Throwable t)
 - 
isTraceEnabledpublic boolean isTraceEnabled() 
 - 
isDebugEnabledpublic boolean isDebugEnabled() 
 - 
isInfoEnabledpublic boolean isInfoEnabled() 
 - 
mdcSetpublic LoggerEx.MDCClosable mdcSet() Sets the registered mdc key/value pairs and returns a closable that can be used to unset them. It is important to note how this system works with this class: The registered key/values are set and unset for every logging operation. However, there are times when the values should stay in the context for a longer period of time, when calling into sub functions (which is more of the traditional use of mdc). In that case, this function can be used to set them. Subsequent calls to logging functions, which normally would have set and unset them, won't remove the keys- only calling close on this returned object (or mdcClose()) will unset them.
 - 
mdcClosepublic void mdcClose() The complementary function to mdcSet, if the AutoClosable return of the set function wasn't used.
 
- 
 
-