You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Kirill A. Korinskiy (JIRA)" <ji...@apache.org> on 2018/07/11 08:57:00 UTC
[jira] [Commented] (LOG4J2-1752) Add ISO8601 format to timestamp in
JSONLayout
[ https://issues.apache.org/jira/browse/LOG4J2-1752?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16539751#comment-16539751 ]
Kirill A. Korinskiy commented on LOG4J2-1752:
---------------------------------------------
Hey, you don't need write any code to do this.
Just adds to your {{log4j.xml}} something like this:
{code}
<Socket name="logz" host="YOUR HOST" port="YOUR POST" reconnectionDelayMillis="5000">
<BurstFilter level="error" rate="50" maxBurst="100"/>
<JsonLayout compact="true" eventEol="true">
<KeyValuePair key="@version" value="1" />
<KeyValuePair key="@timestamp" value="$${date:yyyy-MM-dd'T'HH:mm:ss.SSSXXX}" />
<KeyValuePair key="appname" value="my server" />
<KeyValuePair key="hostname" value="${sys:system.property.with.hostname}"/>
</JsonLayout>
</Socket>
<Async name="ASYNC_logz">
<AppenderRef ref="logz" level="warn"/>
</Async>
{code}
> Add ISO8601 format to timestamp in JSONLayout
> ---------------------------------------------
>
> Key: LOG4J2-1752
> URL: https://issues.apache.org/jira/browse/LOG4J2-1752
> Project: Log4j 2
> Issue Type: Improvement
> Components: Layouts
> Affects Versions: 2.7
> Reporter: Jonas Lindholm
> Priority: Minor
> Labels: json, layout
>
> The [JSONLayout|https://logging.apache.org/log4j/2.x/manual/layouts.html#JSONLayout] formats the timestamp field to timeMillis.
> Moving from [logstash-logback-encoder|https://github.com/logstash/logstash-logback-encoder] it would be nice to be able to format the timestamp with ISO 8601 as the date pattern instead.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)