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

Strainu commented on LOG4J2-3614:
---------------------------------

Sure, here are the extracts from the txt and json logging configs in one 
project. Both aim to display the same timestamp

 

TXT log (working):
{code:java}
<Console name="Console" target="SYSTEM_OUT">
    <PatternLayout pattern="%d{HH:mm:ss.nnnnnnnnn}"/>
</Console> {code}
JSON log:
{code:java}
<JsonTemplateLayout eventTemplateUri="classpath:log-template.json" 
locationInfoEnabled="true">
{code}
 

log-template.json (working):
{code:java}
{
  "time": {
      "$resolver": "timestamp",
      "pattern": {
        "format": "HH:mm:ss.SSSSSSSSS",
        "timezone": "UTC"
      }
  }
} {code}
 

log-template.json (NOT working):
{code:java}
{
  "time": {
      "$resolver": "timestamp",
      "pattern": {
        "format": "HH:mm:ss.nnnnnnnnn",
        "timezone": "UTC"
      }
  }
} {code}
Notice how in the json config I had to use _SSSSSSSSS_ to display nanoseconds, 
while in text I used {_}nnnnnnnnn{_}.

> Update documentation after LOG4J2-3075
> --------------------------------------
>
>                 Key: LOG4J2-3614
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3614
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Documentation
>    Affects Versions: 2.17.2
>            Reporter: Strainu
>            Assignee: Volkan Yazici
>            Priority: Minor
>
> After LOG4J2-3075 was implemented, the JsonTemplateLayout timestamp resolver 
> documentation should be updated to reflect the new feature.
> It's especially important to do so since the second fragment identifier used 
> here ('S') is different from the one described in, e.g. 
> [https://logging.apache.org/log4j/2.x/manual/layouts.html] (which is 'n'). I 
> don't have enough experience with Log4j to determine if this inconsistency is 
> a bug or not, but an entry in the JsonTemplateLayout  documentation would 
> help.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to