Hello Atul, Your investigation of RFC5424 Layout seems to be accurate; the class contains a hardcoded date-time formatting working on millisecond-precision epoch-offset timestamps. I guess two things need to happen:
1. A new layout configuration argument where one can override the date-time format pattern. 2. Switching from the hardcoded date-time formatter to Log4j-provided ones; FastDateFormat, FixedDateFormat, etc. I would suggest checking JsonTemplateLayout's InstantFormatter – the most up-to-date one, AFAIC. These better be placed into a JIRA ticket followed by a GitHub PR. In the meantime, you can copy and adapt the source of Rfc5424Layout in your project, change the plugin name, and use it there. This can serve you until the feature gets implemented and shipped with a release. Kind regards. On Thu, Dec 23, 2021 at 9:38 AM Atul Pendse <apen...@tintri.com.invalid> wrote: > Hi, > > Our application sends syslog messages to a centralized facility which > requires timestamps to be in microsecond format. > Our application was so far using log4j 1.12.5’s Syslog appender to send > syslog messages, which used to format timestamps with microsecond precision. > > We are now upgrading to log4j 2.17.0, and don’t see any way to get > microseconds included in timestamp for syslog. > > I am trying to log messages using SyslogAppender with RFC5424 layout. > I see that RFC5424Layout.java restricts timestamp to millisecond precision > (e.g. 2021-12-22T22:54:33.889-08:00). > > RFC5424 specification also mentions support for microsecond precision. > Here is some text from > https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.3 > > Example 4 > > 2003-08-24T05:14:15.000003-07:00 > > This represents 24 August 2003 at 05:14:15am, 3 microseconds into the > next second. The microsecond resolution is indicated by the > additional digits in TIME-SECFRAC. The timestamp indicates that its > local time is -7 hours from UTC. This timestamp might be created in > the US Pacific time zone during daylight savings time. > > > Is there a way to format timestamp with microsecond precision with > RFC5424Layout? Or is there an alternative way to get timestamp formatted > with microsecond precision for SyslogAppender? > > Any help would be highly appreciated. > > Thanks, > Atul Pendse >