This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new b0fb9a867d Use JSON style format for the instant by default
b0fb9a867d is described below

commit b0fb9a867d3c04bf26bbf57c075457d221c559df
Author: remm <r...@apache.org>
AuthorDate: Mon Feb 10 23:11:06 2025 +0100

    Use JSON style format for the instant by default
---
 java/org/apache/juli/JsonFormatter.java | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/juli/JsonFormatter.java 
b/java/org/apache/juli/JsonFormatter.java
index b0ae7e9576..5947e8ce46 100644
--- a/java/org/apache/juli/JsonFormatter.java
+++ b/java/org/apache/juli/JsonFormatter.java
@@ -16,6 +16,7 @@
  */
 package org.apache.juli;
 
+import java.util.logging.LogManager;
 import java.util.logging.LogRecord;
 
 /**
@@ -25,7 +26,7 @@ import java.util.logging.LogRecord;
  * <p>
  * The LogRecord is mapped as attributes:
  * <ul>
- * <li>time: the log record timestamp</li>
+ * <li>time: the log record timestamp, with the default format as {@code 
yyyy-MM-dd'T'HH:mm:ss.SSSX}</li>
  * <li>level: the log level</li>
  * <li>thread: the current on which the log occurred</li>
  * <li>class: the class from which the log originated</li>
@@ -39,6 +40,16 @@ import java.util.logging.LogRecord;
  */
 public class JsonFormatter extends OneLineFormatter {
 
+    private static final String DEFAULT_TIME_FORMAT = 
"yyyy-MM-dd'T'HH:mm:ss.SSSX";
+
+    public JsonFormatter() {
+        String timeFormat = 
LogManager.getLogManager().getProperty(JsonFormatter.class.getName() + 
".timeFormat");
+        if (timeFormat == null) {
+            timeFormat = DEFAULT_TIME_FORMAT;
+        }
+        setTimeFormat(timeFormat);
+    }
+
     @Override
     public String format(LogRecord record) {
         StringBuilder sb = new StringBuilder();


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to