Description
Discussed in #709
Originally posted by chuckdumont June 17, 2022
Our application uses java.util.logging and handles logging configuration (setting handlers, log levels, etc.). When using esapi with JUL logging, the application's configured log levels are reset by esap. How can we configure esapi to use the java.util.logging APIs to log events, but not try to set it's own logging config?
Recommended Adjustment
If either supported configuration property for the LogManager class exists in the runtime, ESAPI will not apply configuration settings from the esapi-java-logging.properties file
Per the javadoc on the LogManager class, two existing properties may be used to centralize the log configuration:
In addition, the LogManager uses two optional system properties that allow more control over reading the initial configuration:
- "java.util.logging.config.class"
- "java.util.logging.config.file"
These two properties may be set via the Preferences API, or as command line property definitions to the "java" command, or as system property definitions passed to JNI_CreateJavaVM.
The ESAPI JavaLogFactory should not conflict with those settings, if they are defined.
JavaLogFactory.readLoggerConfiguration Additions
/*package*/ static void readLoggerConfiguration(LogManager logManager) {
if (System.getProperties().keySet().stream().anyMatch(propKey -> "java.util.logging.config.class".equals(propKey) || "java.util.logging.config.file".equals(propKey))) {
//LogManager has external configuration. Do not load ESAPI defaults.
return;
}