mirror of
https://github.com/corda/corda.git
synced 2025-03-22 20:15:19 +00:00
Minor: fix the JDK logging bug workaround
This commit is contained in:
parent
9e22cda15c
commit
018825d7d7
@ -56,19 +56,22 @@ class BriefLogFormatter : Formatter() {
|
|||||||
// OpenJDK made a questionable, backwards incompatible change to the Logger implementation. It internally uses
|
// OpenJDK made a questionable, backwards incompatible change to the Logger implementation. It internally uses
|
||||||
// weak references now which means simply fetching the logger and changing its configuration won't work. We must
|
// weak references now which means simply fetching the logger and changing its configuration won't work. We must
|
||||||
// keep a reference to our custom logger around.
|
// keep a reference to our custom logger around.
|
||||||
private lateinit var loggerRef: Logger
|
private val loggerRefs = ArrayList<Logger>()
|
||||||
|
|
||||||
/** Configures JDK logging to use this class for everything. */
|
/** Configures JDK logging to use this class for everything. */
|
||||||
fun init() {
|
fun init() {
|
||||||
loggerRef = Logger.getLogger("")
|
val logger = Logger.getLogger("")
|
||||||
val handlers = loggerRef.handlers
|
val handlers = logger.handlers
|
||||||
handlers[0].formatter = BriefLogFormatter()
|
handlers[0].formatter = BriefLogFormatter()
|
||||||
|
loggerRefs.add(logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initVerbose(packageSpec: String = "") {
|
fun initVerbose(packageSpec: String = "") {
|
||||||
init()
|
init()
|
||||||
loggerRef.handlers[0].level = Level.ALL
|
loggerRefs[0].handlers[0].level = Level.ALL
|
||||||
Logger.getLogger(packageSpec).level = Level.ALL
|
val logger = Logger.getLogger(packageSpec)
|
||||||
|
logger.level = Level.ALL
|
||||||
|
loggerRefs.add(logger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user