23
23
import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
24
24
import java .util .ServiceLoader ;
25
25
import java .util .logging .LogRecord ;
26
+ import org .apache .logging .log4j .jul .spi .LevelChangePropagator ;
26
27
import org .apache .logging .log4j .spi .ExtendedLogger ;
27
28
import org .apache .logging .log4j .status .StatusLogger ;
28
29
import org .apache .logging .log4j .util .ServiceLoaderUtil ;
64
65
* @see <a href="https://logging.apache.org/log4j/3.x/log4j-jul.html">Log4j documentation site</a>
65
66
* @since 2.15.0
66
67
*/
67
- @ ServiceConsumer (value = Log4jBridgeHandler . LevelPropagator .class , cardinality = Cardinality .SINGLE )
68
+ @ ServiceConsumer (value = LevelChangePropagator .class , cardinality = Cardinality .SINGLE )
68
69
public class Log4jBridgeHandler extends java .util .logging .Handler {
69
70
private static final org .apache .logging .log4j .Logger LOGGER = StatusLogger .getLogger ();
70
71
@@ -77,7 +78,7 @@ public class Log4jBridgeHandler extends java.util.logging.Handler {
77
78
78
79
private boolean doDebugOutput = false ;
79
80
private String julSuffixToAppend = null ;
80
- private LevelPropagator levelPropagator ;
81
+ private LevelChangePropagator levelPropagator ;
81
82
private volatile boolean installAsLevelPropagator = false ;
82
83
83
84
/**
@@ -135,8 +136,9 @@ private void configure(String suffixToAppend, boolean propagateLevels) {
135
136
installAsLevelPropagator = propagateLevels ;
136
137
if (installAsLevelPropagator ) {
137
138
levelPropagator = ServiceLoaderUtil .safeStream (
138
- LevelPropagator .class ,
139
- ServiceLoader .load (LevelPropagator .class , getClass ().getClassLoader ()),
139
+ LevelChangePropagator .class ,
140
+ ServiceLoader .load (
141
+ LevelChangePropagator .class , getClass ().getClassLoader ()),
140
142
LOGGER )
141
143
.findAny ()
142
144
.orElse (null );
@@ -216,30 +218,4 @@ private org.apache.logging.log4j.Logger getLog4jLogger(final LogRecord record) {
216
218
}
217
219
return org .apache .logging .log4j .LogManager .getLogger (name );
218
220
}
219
-
220
- /**
221
- * Propagates level configuration from the Log4j API implementation used
222
- * <p>
223
- * Using the {@link Log4jBridgeHandler} is expensive, since disabled log events must be formatted by JUL,
224
- * before they can be dropped by the Log4j API implementation.
225
- * </p>
226
- * <p>
227
- * This class introduces a mechanism that can be implemented by each Log4j API implementation to be notified,
228
- * whenever a {@link Log4jBridgeHandler} is used. The logging implementation will be able to synchronize
229
- * its levels with the levels of JUL loggers each time it is reconfigured.
230
- * </p>
231
- * @since 3.0.0
232
- */
233
- public interface LevelPropagator {
234
-
235
- /**
236
- * Start propagating log levels.
237
- */
238
- void start ();
239
-
240
- /**
241
- * Stop propagating log levels.
242
- */
243
- void stop ();
244
- }
245
221
}
0 commit comments