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

Kirill A. Korinskiy edited comment on LOG4J2-1752 at 7/11/18 8:57 AM:
----------------------------------------------------------------------

Hey, you don't need write any code to do this.

Just adds to your {{log4j.xml}} something like this:
{code}
    <Appenders>
        <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>
    </Appenders>
    <Loggers>
        <asyncRoot level="info">
            <AppenderRef ref="ASYNC_logz" level="warn" />
        </asyncRoot>
        </asyncLogger>
    </Loggers>
{code}


was (Author: catap):
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)

Reply via email to