From 0c9195011aace5f923d37cd7fd402ff774f9dc1c Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Sun, 5 Feb 2017 11:20:00 +0100 Subject: [PATCH] use log4j in pdb-ui --- pdb-ui/build.gradle | 5 ++++- .../org/lucares/performance/db/PerformanceDb.java | 11 ++++++----- performanceDb/src/main/resources/log4j2.properties | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pdb-ui/build.gradle b/pdb-ui/build.gradle index c981be8..54bb54e 100644 --- a/pdb-ui/build.gradle +++ b/pdb-ui/build.gradle @@ -8,7 +8,10 @@ dependencies { compile project(':performanceDb') compile project(':pdb-plotting') - compile("org.springframework.boot:spring-boot-starter-web:1.5.1.RELEASE") + compile("org.springframework.boot:spring-boot-starter-web:1.5.1.RELEASE"){ + exclude module: 'spring-boot-starter-logging' + } + compile("org.springframework.boot:spring-boot-starter-log4j2:1.5.1.RELEASE") testCompile("org.springframework.boot:spring-boot-starter-test:1.5.1.RELEASE") } \ No newline at end of file diff --git a/performanceDb/src/main/java/org/lucares/performance/db/PerformanceDb.java b/performanceDb/src/main/java/org/lucares/performance/db/PerformanceDb.java index c6ca215..464d6a6 100644 --- a/performanceDb/src/main/java/org/lucares/performance/db/PerformanceDb.java +++ b/performanceDb/src/main/java/org/lucares/performance/db/PerformanceDb.java @@ -11,7 +11,6 @@ import java.util.Optional; import java.util.Spliterator; import java.util.Spliterators; import java.util.concurrent.BlockingQueue; -import java.util.logging.Logger; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -23,9 +22,11 @@ import org.lucares.pdb.api.Entry; import org.lucares.pdb.api.GroupResult; import org.lucares.pdb.api.Result; import org.lucares.pdb.api.Tags; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PerformanceDb implements AutoCloseable, CollectionUtils { - private static final Logger LOGGER = Logger.getLogger(PerformanceDb.class.getCanonicalName()); + private final static Logger LOGGER = LoggerFactory.getLogger(PerformanceDb.class); private final TagsToFile tagsToFile; @@ -84,7 +85,7 @@ public class PerformanceDb implements AutoCloseable, CollectionUtils { if (count % blocksize == 0) { final long end = System.nanoTime(); final double duration = (end - start) / 1_000_000.0; - LOGGER.info("inserting the last " + blocksize + " took " + duration + " ms; " + Stats.duration + LOGGER.debug("inserting the last " + blocksize + " took " + duration + " ms; " + Stats.duration + "ms of " + Stats.count + " operations. total entries: " + count / 1_000_000.0 + " million"); @@ -107,7 +108,7 @@ public class PerformanceDb implements AutoCloseable, CollectionUtils { LOGGER.info("Thread was interrupted. Aborting exectution."); } finally { tagsToFile.flush(); - LOGGER.info("flushed all files."); + LOGGER.debug("flushed all files."); } } @@ -159,7 +160,7 @@ public class PerformanceDb implements AutoCloseable, CollectionUtils { try { iterator.close(); } catch (final RuntimeException e) { - e.printStackTrace(); + LOGGER.info("runtime exception while closing iterator", e); } }); return result; diff --git a/performanceDb/src/main/resources/log4j2.properties b/performanceDb/src/main/resources/log4j2.properties index c70bf9f..ac5129b 100644 --- a/performanceDb/src/main/resources/log4j2.properties +++ b/performanceDb/src/main/resources/log4j2.properties @@ -9,5 +9,5 @@ appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%t] %c -rootLogger.level = trace -rootLogger.appenderRef.stdout.ref = STDOUT \ No newline at end of file +rootLogger.level = info +rootLogger.appenderRef.stdout.ref = STDOUT