You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Ralph Goers (Jira)" <ji...@apache.org> on 2021/11/27 18:20:00 UTC
[jira] [Commented] (LOG4J2-3197) Support agentless logging to Datadog
[ https://issues.apache.org/jira/browse/LOG4J2-3197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17449903#comment-17449903 ]
Ralph Goers commented on LOG4J2-3197:
-------------------------------------
This is incredibly simple to implement. The configuration would look like:
{code:java}
<Appenders>
<Socket name=“JSON_TCP" host=“intake.logs.datadoghq.com" port=“10516" protocol=“SSL" bufferedIo="true" ignoreExceptions="false”>
<PrefixSuffixLayout prefix=“${env:DD_API_KEY}”>
<JsonTemplateLayout includeLocation=“${includeLocation:-true}” eventTemplateUri=“classpath:mytemplate.json”/>
</PrefixSuffixLayout>
</Socket>
</Appenders>
{code}
PrefixSuffixLayout would simply emit the prefix before calling the embedded layout and then emit the suffix afterwards.
Alternately, this could be done by simply adding a new LayoutConverter to the PatternLayout that would allow PatternLayout to wrap another Layout. I think I actually like this solution better as it provides a huge range of capabilities.
> Support agentless logging to Datadog
> ------------------------------------
>
> Key: LOG4J2-3197
> URL: https://issues.apache.org/jira/browse/LOG4J2-3197
> Project: Log4j 2
> Issue Type: Improvement
> Components: Layouts
> Affects Versions: 2.14.1
> Reporter: Mikael Ståldal
> Assignee: Volkan Yazici
> Priority: Minor
>
> The documentation for Datadog contains information on how to setup Log4j 2 to send logs to Datadog. However, for the agentless configuration, it says its not possible with Log4j 2 and resorts to bridging to Logback:
> [https://docs.datadoghq.com/logs/log_collection/java/?tab=log4j2#agentless-logging]
> The problem is that the JSON formatted log events needs to be prefixed with an API key (outside of the JSON structure). This is possible with Logback, but supposedly not with Log4j 2.
> This configuration is arguably a bit strange, but it would be good if Log4j 2 could support it, since it is likely a relevant use case.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)