Class Log4j2LevelAdjuster
java.lang.Object
org.springframework.integration.test.rule.Log4j2LevelAdjuster
- All Implemented Interfaces:
org.junit.rules.MethodRule
A JUnit method
Rule
that changes the Log4J 2 logger level for a set of classes
or packages while a test method is running. Useful for performance or scalability tests
where we don't want to generate a large log in a tight inner loop, or
enabling debug logging for a test case.- Since:
- 5.0.1
- Author:
- Artem Bilan, Gary Russell
-
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target) categories
(boolean merge, String... categories) Specify the categories for logging level adjusting configured before.categories
(String... categoriesToAdjust) Specify the categories for logging level adjusting configured before.Specify the classes for logging level adjusting configured before.Specify the classes for logging level adjusting configured before.static Log4j2LevelAdjuster
debug()
The factory to produce Log4j2LevelAdjuster instances forLevel.DEBUG
logging with theorg.springframework.integration
as default category.static Log4j2LevelAdjuster
forLevel
(org.apache.logging.log4j.Level level) The factory to produce Log4j2LevelAdjuster instances for arbitrary loggingLevel
with theorg.springframework.integration
as default category.static Log4j2LevelAdjuster
info()
The factory to produce Log4j2LevelAdjuster instances forLevel.INFO
logging with theorg.springframework.integration
as default category.static Log4j2LevelAdjuster
trace()
The factory to produce Log4j2LevelAdjuster instances forLevel.TRACE
logging with theorg.springframework.integration
as default category.
-
Method Details
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target) - Specified by:
apply
in interfaceorg.junit.rules.MethodRule
-
classes
Specify the classes for logging level adjusting configured before. A new copy Log4j2LevelAdjuster instance is produced by this method. The provided classes parameter overrides existing value in theclasses
.- Parameters:
clazzes
- the classes to use for logging level adjusting- Returns:
- a Log4j2LevelAdjuster copy with the provided classes
-
classes
Specify the classes for logging level adjusting configured before. A new copy Log4j2LevelAdjuster instance is produced by this method. The provided classes parameter can be merged with existing value in theclasses
.- Parameters:
merge
- to merge or not with previously configuredclasses
classesToAdjust
- the classes to use for logging level adjusting- Returns:
- a Log4j2LevelAdjuster copy with the provided classes
- Since:
- 5.0.2
-
categories
Specify the categories for logging level adjusting configured before. A new copy Log4j2LevelAdjuster instance is produced by this method. The provided categories parameter overrides existing value in thecategories
.- Parameters:
categoriesToAdjust
- the categories to use for logging level adjusting- Returns:
- a Log4j2LevelAdjuster copy with the provided categories
-
categories
Specify the categories for logging level adjusting configured before. A new copy Log4j2LevelAdjuster instance is produced by this method. The provided categories parameter can be merged with existing value in thecategories
.- Parameters:
merge
- to merge or not with previously configuredcategories
categories
- the categories to use for logging level adjusting- Returns:
- a Log4j2LevelAdjuster copy with the provided categories
- Since:
- 5.0.2
-
trace
The factory to produce Log4j2LevelAdjuster instances forLevel.TRACE
logging with theorg.springframework.integration
as default category.- Returns:
- the Log4j2LevelAdjuster instance
-
debug
The factory to produce Log4j2LevelAdjuster instances forLevel.DEBUG
logging with theorg.springframework.integration
as default category.- Returns:
- the Log4j2LevelAdjuster instance
-
info
The factory to produce Log4j2LevelAdjuster instances forLevel.INFO
logging with theorg.springframework.integration
as default category.- Returns:
- the Log4j2LevelAdjuster instance
-
forLevel
The factory to produce Log4j2LevelAdjuster instances for arbitrary loggingLevel
with theorg.springframework.integration
as default category.- Parameters:
level
- theLevel
to use for logging- Returns:
- the Log4j2LevelAdjuster instance
-