-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed
Description
// java version "12.0.1" 2019-04-16
// Java(TM) SE Runtime Environment (build 12.0.1+12)
// Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
//
// org.springframework.boot:spring-boot:2.1.5.RELEASE
import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.logging.java.JavaLoggingSystem;
import java.util.logging.Level;
import java.util.logging.Logger;
var logger = "some.logger";
var loggingSystem = new JavaLoggingSystem(getClass().getClassLoader());
loggingSystem.setLogLevel(logger, LogLevel.TRACE);
// Just configured logger works as expected.
assert Logger.getLogger(logger).isLoggable(Level.FINEST);
// But configuration and usage are usually separated in time,
// GC may happen between `LoggingApplicationListener.initializeFinalLoggingLevels`
// and obtaining logger (e.g. static log field initialization).
// JUL LogManager uses weak references to store loggers.
// Spring JavaLoggingSystem doesn't hold strong references to configured loggers.
System.gc();
// So configuration may be lost :(
assert Logger.getLogger(logger).isLoggable(Level.FINEST);Maybe JavaLoggingSystem should keep strong references to configured loggers?
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug