Package nva.commons.logutils
Class LogUtils
java.lang.Object
nva.commons.logutils.LogUtils
Methods for testing logging when using Log4j2 as logging platform. Can be used when using SLF4J as well with Log4j2
as background logging platform.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TestAppendergetTestingAppender(Class<T> clazz) This method should ALWAYS be called before the creation of the object you want to test.static <T> TestAppenderThis method should ALWAYS be called before the creation of the object you want to test.static StringtoLoggerName(Class<?> cls) From LogManager.getLogger()
-
Field Details
-
PATTERN_ATTRIBUTE_NAME
- See Also:
-
LOG_CLASS_NAME_AND_MESSAGE
- See Also:
-
ROOT_NULL_APPENDER
- See Also:
-
PACKAGES_WITH_APPENDERS
- See Also:
-
-
Method Details
-
getTestingAppender
This method should ALWAYS be called before the creation of the object you want to test.The method was created based on the patterns for programmatically configuring Log4j (https://logging.apache.org/log4j/2.x/manual/customconfig.html)
- Type Parameters:
T- The class of the object under test- Parameters:
clazz- The class of the object under test.- Returns:
- a
TestAppender
-
getTestingAppenderForRootLogger
This method should ALWAYS be called before the creation of the object you want to test.The method was created based on the patterns for programmatically configuring Log4j (https://logging.apache.org/log4j/2.x/manual/customconfig.html)
- Type Parameters:
T- The class of the object under test- Returns:
- a
TestAppender
-
toLoggerName
From LogManager.getLogger()- Parameters:
cls- the class- Returns:
- the logger name
-