You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2016/01/09 07:33:39 UTC

[jira] [Commented] (LOG4J2-1248) PatternLayout Nano timestamp does not work

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

Remko Popma commented on LOG4J2-1248:
-------------------------------------

The current implementation was fragile since it depended on methods being called in a certain order. PatternParser essentially sets a global variable every time a pattern is parsed. When a pattern uses the nano time conversion pattern, the system nano clock is set, otherwise the default dummy nano clock is set. This global variable is then referenced on reconfiguration. However, if a different pattern without a nano time is parsed before reconfiguration, the global variable is overridden.

The solution is to make NanoClock a field of the Configuration, with an initial dummy nano clock value. PatternParser now only modifies its Configuration's nano clock when it detects a nano time conversion pattern.

> PatternLayout Nano timestamp does not work
> ------------------------------------------
>
>                 Key: LOG4J2-1248
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1248
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Layouts, Pattern Converters
>    Affects Versions: 2.5
>            Reporter: Remko Popma
>            Assignee: Remko Popma
>             Fix For: 2.5.1
>
>
> As reported by jiri463 on [StackOverflow|http://stackoverflow.com/questions/34683550/log4j-2-5-patternlayout-nano-timestamp-does-not-work], specifying %nano in a pattern layout always renders zero values instead of the expected nanotime.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org