diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2021-02-05 10:22:51 +0100 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2021-02-05 10:22:51 +0100 |
commit | 53cf2ec2d41ad68c6427231ff1575d6a13c4f795 (patch) | |
tree | ee002d13f8fb5b58bd11ed6db5d3c54f3ba6492b /jdisc_http_service | |
parent | 1691b77f23c5cceb9141403a79441d78c3de797d (diff) |
Use separate name per logger thread
Diffstat (limited to 'jdisc_http_service')
4 files changed, 16 insertions, 10 deletions
diff --git a/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogHandler.java b/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogHandler.java index 376be879965..89aab1513ee 100644 --- a/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogHandler.java +++ b/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogHandler.java @@ -11,7 +11,9 @@ class AccessLogHandler { private final LogFileHandler<RequestLogEntry> logFileHandler; AccessLogHandler(AccessLogConfig.FileHandler config, LogWriter<RequestLogEntry> logWriter) { - logFileHandler = new LogFileHandler<>(toCompression(config), config.pattern(), config.rotation(), config.symlink(), config.queueSize(), logWriter); + logFileHandler = new LogFileHandler<>( + toCompression(config), config.pattern(), config.rotation(), + config.symlink(), config.queueSize(), "request-logger", logWriter); } public void log(RequestLogEntry entry) { diff --git a/jdisc_http_service/src/main/java/com/yahoo/container/logging/ConnectionLogHandler.java b/jdisc_http_service/src/main/java/com/yahoo/container/logging/ConnectionLogHandler.java index 38d979e8138..7a0e8aca95e 100644 --- a/jdisc_http_service/src/main/java/com/yahoo/container/logging/ConnectionLogHandler.java +++ b/jdisc_http_service/src/main/java/com/yahoo/container/logging/ConnectionLogHandler.java @@ -15,6 +15,7 @@ class ConnectionLogHandler { "0 60 ...", String.format("ConnectionLog.%s", clusterName), queueSize, + "connection-logger", logWriter); } diff --git a/jdisc_http_service/src/main/java/com/yahoo/container/logging/LogFileHandler.java b/jdisc_http_service/src/main/java/com/yahoo/container/logging/LogFileHandler.java index 5aca804ba64..b2d7dd80b7f 100644 --- a/jdisc_http_service/src/main/java/com/yahoo/container/logging/LogFileHandler.java +++ b/jdisc_http_service/src/main/java/com/yahoo/container/logging/LogFileHandler.java @@ -46,8 +46,9 @@ class LogFileHandler <LOGTYPE> { @FunctionalInterface private interface Pollable<T> { Operation<T> poll() throws InterruptedException; } - LogFileHandler(Compression compression, String filePattern, String rotationTimes, String symlinkName, int queueSize, LogWriter<LOGTYPE> logWriter) { - this(compression, filePattern, calcTimesMinutes(rotationTimes), symlinkName, queueSize, logWriter); + LogFileHandler(Compression compression, String filePattern, String rotationTimes, String symlinkName, int queueSize, + String threadName, LogWriter<LOGTYPE> logWriter) { + this(compression, filePattern, calcTimesMinutes(rotationTimes), symlinkName, queueSize, threadName, logWriter); } LogFileHandler( @@ -56,9 +57,10 @@ class LogFileHandler <LOGTYPE> { long[] rotationTimes, String symlinkName, int queueSize, + String threadName, LogWriter<LOGTYPE> logWriter) { this.logQueue = new LinkedBlockingQueue<>(queueSize); - this.logThread = new LogThread<LOGTYPE>(logWriter, filePattern, compression, rotationTimes, symlinkName, this::poll); + this.logThread = new LogThread<>(logWriter, filePattern, compression, rotationTimes, symlinkName, threadName, this::poll); this.logThread.start(); } @@ -205,8 +207,9 @@ class LogFileHandler <LOGTYPE> { Compression compression, long[] rotationTimes, String symlinkName, + String threadName, Pollable<LOGTYPE> operationProvider) { - super("Logger"); + super(threadName); setDaemon(true); this.logWriter = logWriter; this.filePattern = filePattern; diff --git a/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java b/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java index 7ae46f50492..8f78530327e 100644 --- a/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java +++ b/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java @@ -43,7 +43,7 @@ public class LogFileHandlerTestCase { String pattern = root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S"; long[] rTimes = {1000, 2000, 10000}; - LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, pattern, rTimes, null, 2048, new StringLogWriter()); + LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, pattern, rTimes, null, 2048, "thread-name", new StringLogWriter()); long now = System.currentTimeMillis(); long millisPerDay = 60*60*24*1000; long tomorrowDays = (now / millisPerDay) +1; @@ -65,7 +65,7 @@ public class LogFileHandlerTestCase { File logFile = temporaryFolder.newFile("testLogFileG1.txt"); //create logfilehandler - LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, logFile.getAbsolutePath(), "0 5 ...", null, 2048, new StringLogWriter()); + LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, logFile.getAbsolutePath(), "0 5 ...", null, 2048, "thread-name", new StringLogWriter()); //write log h.publish("testDeleteFileFirst1"); @@ -78,7 +78,7 @@ public class LogFileHandlerTestCase { File logFile = temporaryFolder.newFile("testLogFileG2.txt"); //create logfilehandler - LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, logFile.getAbsolutePath(), "0 5 ...", null, 2048, new StringLogWriter()); + LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, logFile.getAbsolutePath(), "0 5 ...", null, 2048, "thread-name", new StringLogWriter()); //write log h.publish("testDeleteFileDuringLogging1"); @@ -104,7 +104,7 @@ public class LogFileHandlerTestCase { } }; LogFileHandler<String> handler = new LogFileHandler<>( - Compression.NONE, root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S%s", new long[]{0}, "symlink", 2048, new StringLogWriter()); + Compression.NONE, root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S%s", new long[]{0}, "symlink", 2048, "thread-name", new StringLogWriter()); String message = formatter.format(new LogRecord(Level.INFO, "test")); handler.publishAndWait(message); @@ -150,7 +150,7 @@ public class LogFileHandlerTestCase { File root = temporaryFolder.newFolder("testcompression" + compression.name()); LogFileHandler<String> h = new LogFileHandler<>( - compression, root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S%s", new long[]{0}, null, 2048, new StringLogWriter()); + compression, root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S%s", new long[]{0}, null, 2048, "thread-name", new StringLogWriter()); int logEntries = 10000; for (int i = 0; i < logEntries; i++) { h.publish("test"); |