Tidy up DemoBench's fallback logging configuration for JUL. (#3894)

This commit is contained in:
Chris Rankin 2018-09-05 12:14:35 +01:00 committed by GitHub
parent be45096082
commit 7f3bcbe7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ import java.util.logging.*;
* to be added to the JVM's command line.
*/
public class LoggingConfig {
private static final String LOGGING_CONFIG = "logging.properties";
public LoggingConfig() throws IOException {
try (InputStream input = getLoggingProperties()) {
@ -20,10 +21,11 @@ public class LoggingConfig {
private static InputStream getLoggingProperties() throws IOException {
ClassLoader classLoader = LoggingConfig.class.getClassLoader();
InputStream input = classLoader.getResourceAsStream("logging.properties");
InputStream input = classLoader.getResourceAsStream(LOGGING_CONFIG);
if (input == null) {
Path javaHome = Paths.get(System.getProperty("java.home"));
input = Files.newInputStream(javaHome.resolve("lib").resolve("logging.properties"));
// Use the default JUL logging configuration properties instead.
Path logging = Paths.get(System.getProperty("java.home"), "lib", LOGGING_CONFIG);
input = Files.newInputStream(logging, StandardOpenOption.READ);
}
return input;
}