[
https://issues.apache.org/jira/browse/LOG4J2-3367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17483626#comment-17483626
]
Volkan Yazici commented on LOG4J2-3367:
---------------------------------------
Hey [~matejko219]! Thanks for reaching out to us. You don't need to delegate to
{{PatternLayout}} to perform lookups, [{{JsonTemplateLayout}} supports
lookups|https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#faq-lookups]
too. Hence in your configuration, you can simply use the following:
{code:json}
{
"service": {
"name": "${serviceName}"
}
}
{code}
The following configuration works for me:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Properties>
<Property name="year">${date:yyyy}</Property>
</Properties>
<Appenders>
<Console name="CONSOLE">
<JsonTemplateLayout eventTemplate='"${year}"'/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="CONSOLE"/>
</Root>
</Loggers>
</Configuration>
{code}
Would you mind giving this a try and see if it works, please?
> Issue with log4j-layout-template-json pattern resolver
> ------------------------------------------------------
>
> Key: LOG4J2-3367
> URL: https://issues.apache.org/jira/browse/LOG4J2-3367
> Project: Log4j 2
> Issue Type: Bug
> Components: JsonTemplateLayout
> Affects Versions: 2.17.1, 2.17.0
> Reporter: Mateusz Tumidajewicz
> Assignee: Volkan Yazici
> Priority: Minor
>
> After upgrade to 2.17.1 my template stopped working as expected:
> part of template.json definition of service.name property
> {code:java}
> "service": {
> "name": {
> "$resolver": "pattern",
> "pattern": "${serviceName}",
> "stackTraceEnabled": false
> } {code}
> part of log4j2.xml definition of serviceName property
> {code:java}
> <Properties>
> <Property
> name="serviceName">${bundle:META-INF/build-info:build.artifact}</Property>
> </Properties>{code}
> Before upgrade each log contained build.artifact value from
> META-INF/build-info.properties file. Now it contains only
> "${bundle:META-INF/build-info:build.artifact}"
> It worked up to 2.16.0
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)