[ 
https://issues.apache.org/jira/browse/LOG4J2-1883?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15975936#comment-15975936
 ] 

Remko Popma commented on LOG4J2-1883:
-------------------------------------

[~Anthony Maire] Thanks for the in-depth analysis! FYI, all time stamp in 
Log4j2 are currently provided by a 
[Clock|https://logging.apache.org/log4j/2.x/log4j-core/xref/org/apache/logging/log4j/core/util/Clock.html]
 interface that lives in the util package of the core module. Instances of this 
interface are produced by the ClockFactory in that same package. 

As you pointed out, we would like something that is garbage free and works 
(perhaps with less precision) on Java 7. 

API-wise, we can add a {{PreciseClock}} interface that extends the Log4j2 Clock 
interface. Instances can be obtained from the same ClockFactory. 
What this interface should look like needs some thought. One option is that the 
caller offers a mutable data structure to the PreciseClock which the 
PreciseClock will initialize. 
 
A pure Java implementation will likely need to call 
{{java.time.Clock::instant}} to populate the data structure with the desired 
precision which is unfortunately not garbage free. 

Finally, the  LogEvent interface will need an additional method returning this 
data structure.

> Timestamp does not seem to support microseconds level
> -----------------------------------------------------
>
>                 Key: LOG4J2-1883
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1883
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators
>         Environment: Linux with any JDK including JDK1.8
>            Reporter: Madhava Dass
>            Priority: Critical
>
> Used log4j and 'log4j2.xml' to configure timestamp format as:
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="WARN">
>     <Appenders>
>         <Console name="Console" target="SYSTEM_OUT">
>             <PatternLayout 
> pattern="[%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}{UTC}][%level][%logger{36}]:%msg%n"/>
>         </Console>
>     </Appenders>
>     <Loggers>
>         <Root level="DEBUG">
>             <AppenderRef ref="Console"/>
>         </Root>
>     </Loggers>
> </Configuration>
> {code}
> This pattern produces the time stamp as:
> {code}
> [2017-03-29T13:55:28.363000][null]:[Thread-1]: - <message>
> {code}
> The desired output is:
> {code}
> [2017-03-29T13:55:28.363701-07:00][null]:[Thread-1]: - <message>
> {code}
> Different versions of JDKs were tried including JDK 1.8. It does not seem to 
> make any difference in the outcome.
> Is there a way to get the desired time stamp through pattern matching 
> configuration in the '*.xml' file?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to