diff --git a/src/org/omegat/logger.properties b/src/org/omegat/logger.properties index dbcd046734..dd5cc9a0fb 100644 --- a/src/org/omegat/logger.properties +++ b/src/org/omegat/logger.properties @@ -8,16 +8,19 @@ org.omegat.level = ALL java.util.logging.ConsoleHandler.level = ALL org.omegat.util.logging.OmegaTFileHandler.level = ALL -org.omegat.util.logging.OmegaTLogFormatter.mask=$mark: $level: $text $key +org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $level: $text $key #org.omegat.util.logging.OmegaTLogFormatter.mask=$time: $threadName [$level] $key $text +#org.omegat.util.logging.OmegaTLogFormatter.mask=$mark: $level: $text $key -org.omegat.util.logging.OmegaTLogFormatter.timeFormat=HH:mm:ss,SSSS +org.omegat.util.logging.OmegaTLogFormatter.timeFormat=HH:mm:ss.SSS java.util.logging.ConsoleHandler.formatter = org.omegat.util.logging.OmegaTLogFormatter org.omegat.util.logging.OmegaTFileHandler.formatter = org.omegat.util.logging.OmegaTLogFormatter org.omegat.util.logging.OmegaTFileHandler.size=1048576 org.omegat.util.logging.OmegaTFileHandler.count=10 +# 20 days * 24 hours * 60 min * 60 sec = 1,020,000 seconds +org.omegat.util.logging.OmegaTFileHandler.retention=1020000 # precise control of log levels, please change when debug org.omegat.core.data.level = INFO diff --git a/src/org/omegat/util/Log.java b/src/org/omegat/util/Log.java index b36b2bee9b..4ae381383a 100644 --- a/src/org/omegat/util/Log.java +++ b/src/org/omegat/util/Log.java @@ -35,7 +35,6 @@ import java.io.IOException; import java.io.InputStream; import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; import java.util.Properties; import java.util.concurrent.ThreadLocalRandom; import java.util.logging.Formatter; @@ -63,14 +62,14 @@ public final class Log { // Line mark is day-of-the-year and five-character random number private static final String SESSION_ID; - private static final String SESSION_START_DATETIME; + private static final ZonedDateTime SESSION_START_DATETIME; private Log() { } static { SESSION_ID = String.format("%05d", ThreadLocalRandom.current().nextInt(100000)); - SESSION_START_DATETIME = DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(ZonedDateTime.now()); + SESSION_START_DATETIME = ZonedDateTime.now(); LOGGER = LoggerFactory.getLogger(ILogger.ROOT_LOGGER_NAME, OStrings.getResourceBundle()); init(); @@ -80,7 +79,7 @@ public static String getSessionId() { return SESSION_ID; } - public static String getSessionStartDateTime() { + public static ZonedDateTime getSessionStartDateTime() { return SESSION_START_DATETIME; } diff --git a/src/org/omegat/util/logging/OmegaTFileHandler.java b/src/org/omegat/util/logging/OmegaTFileHandler.java index 529448bda2..554fa09ab0 100644 --- a/src/org/omegat/util/logging/OmegaTFileHandler.java +++ b/src/org/omegat/util/logging/OmegaTFileHandler.java @@ -34,6 +34,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; +import java.time.format.DateTimeFormatter; import java.util.logging.ErrorManager; import java.util.logging.Level; import java.util.logging.LogManager; @@ -115,7 +116,7 @@ private void openFiles(final File dir) throws IOException { boolean ignored = dir.mkdirs(); for (int instanceIndex = 0; instanceIndex < 100; instanceIndex++) { String fileName = String.format("%s_%s_%s%s", OStrings.getApplicationName(), Log.getSessionId(), - Log.getSessionStartDateTime(), + DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss").format(Log.getSessionStartDateTime()), // Instance index instanceIndex > 0 ? ("-" + instanceIndex) : "");