Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1883

Support precise timestamps (microsecond and nanosecond level)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.11.0
    • Configurators
    • None
    • Java 9

    Description

      Used log4j and 'log4j2.xml' to configure timestamp format as:

      <?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>
      

      This pattern produces the time stamp as:

      [2017-03-29T13:55:28.363000][null]:[Thread-1]: - <message>
      

      The desired output is:

      [2017-03-29T13:55:28.363701-07:00][null]:[Thread-1]: - <message>
      

      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?

      Attachments

        Issue Links

          Activity

            People

              rpopma Remko Popma
              madhav.dass@oracle.com Madhava Dass
              Votes:
              1 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: