You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Benjamin Tanguay (Jira)" <ji...@apache.org> on 2022/05/04 19:08:00 UTC

[jira] [Updated] (LOG4J2-3498) Timestamp lacks micro and nano second precision on linux

     [ https://issues.apache.org/jira/browse/LOG4J2-3498?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Tanguay updated LOG4J2-3498:
-------------------------------------
    Description: 
Generating a timestamp with micro and nano seconds defined fails when the operating system is linux. Instead of having the required precision, the log pads the micro and nano seconds with zeros. Testing it between some developpers, the code works properly on Windows and Mac and only fails on Linux machines.

Our team has tested this internally and it seems that the problem is linked to a bad interaction between Linux and the library. We've tested with different JDK versions and vendors and the problem remained the same. The problem also works in the same way whether we use a JsonLayout or a PatternLayout to output the timestamp in the log.

 

{*}Expected{*}:

A timestamp with the form: "timestamp":"2022-05-04T17:53:43.914{*}123456{*}Z"

{*}Actual{*}:

A timestamp with the form: "timestamp":"2022-05-04T17:53:43.914{*}000000{*}Z"

 

I created a small project to reproduce the issue. Notice the script demo.sh that allows you to build an alpine image, execute the code in docker and output the log in the console.

[https://github.com/BenjaminTanguay/log4j-low-timestamp-precision-linux-demo]

 

  was:
Generating a timestamp with micro and nano seconds defined fails when the operating system is linux. Instead of having the required precision, the log pads the micro and nano seconds with zeros. Testing it between some developpers, the code works properly on Windows and Mac and only fails on Linux machines.

Our team has tested this internally and it seems that the problem is linked to a bad interaction between Linux and the library. We've tested with different JDK versions and vendors and the problem remained the same. The problem also works in the same way whether we use a JsonLayout or a PatternLayout to output the timestamp in the log.

 

{*}Expected{*}:

A timestamp with the form: "timestamp":"2022-05-04T17:53:43.914{*}123456{*}Z"

Actual:

A timestamp with the form: "timestamp":"2022-05-04T17:53:43.914{*}000000{*}Z"

 

I created a small project to reproduce the issue. Notice the script demo.sh that allows you to build an alpine image, execute the code in docker and output the log in the console.

[https://github.com/BenjaminTanguay/log4j-low-timestamp-precision-linux-demo]

 


> Timestamp lacks micro and nano second precision on linux
> --------------------------------------------------------
>
>                 Key: LOG4J2-3498
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3498
>             Project: Log4j 2
>          Issue Type: Bug
>            Reporter: Benjamin Tanguay
>            Priority: Minor
>
> Generating a timestamp with micro and nano seconds defined fails when the operating system is linux. Instead of having the required precision, the log pads the micro and nano seconds with zeros. Testing it between some developpers, the code works properly on Windows and Mac and only fails on Linux machines.
> Our team has tested this internally and it seems that the problem is linked to a bad interaction between Linux and the library. We've tested with different JDK versions and vendors and the problem remained the same. The problem also works in the same way whether we use a JsonLayout or a PatternLayout to output the timestamp in the log.
>  
> {*}Expected{*}:
> A timestamp with the form: "timestamp":"2022-05-04T17:53:43.914{*}123456{*}Z"
> {*}Actual{*}:
> A timestamp with the form: "timestamp":"2022-05-04T17:53:43.914{*}000000{*}Z"
>  
> I created a small project to reproduce the issue. Notice the script demo.sh that allows you to build an alpine image, execute the code in docker and output the log in the console.
> [https://github.com/BenjaminTanguay/log4j-low-timestamp-precision-linux-demo]
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)