You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "youngledo (via GitHub)" <gi...@apache.org> on 2024/08/16 06:23:00 UTC
[I] JSON layout does not display line numbers (logging-log4j2)
youngledo opened a new issue, #2844:
URL: https://github.com/apache/logging-log4j2/issues/2844
## Description
Using JSON layout and configuring line numbers, but not in the file, but the console can display.
## Configuration
**Version:** 2.17.2
**Operating system:** macOS Sonoma 14.6
**JDK:** 8
## Logs
- File
<img width="1056" alt="image" src="https://github.com/user-attachments/assets/554896e1-0257-49bf-8979-be8cdd9defb7">
- Console
<img width="627" alt="image" src="https://github.com/user-attachments/assets/61b25080-b20a-499a-a091-1b6607fba88d">
## Reproduction
The example project is as follows:
[no-line-number.zip](https://github.com/user-attachments/files/16633678/no-line-number.zip)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] JSON layout does not display line numbers (logging-log4j2)
Posted by "youngledo (via GitHub)" <gi...@apache.org>.
youngledo commented on issue #2844:
URL: https://github.com/apache/logging-log4j2/issues/2844#issuecomment-2301239212
Also, can't JSON templates use the 'ThreadContext'?
I found that the '%X' in the template is invalid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] JSON layout does not display line numbers (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz closed issue #2844: JSON layout does not display line numbers
URL: https://github.com/apache/logging-log4j2/issues/2844
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] JSON layout does not display line numbers (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz closed issue #2844: JSON layout does not display line numbers
URL: https://github.com/apache/logging-log4j2/issues/2844
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] JSON layout does not display line numbers (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #2844:
URL: https://github.com/apache/logging-log4j2/issues/2844#issuecomment-2292937419
JSON Template Layout does not print the location by default. You need to set its `locationInfoEnabled` attribute to `true` in order to enable it:
```xml
<JsonTemplateLayout eventTemplateUri="classpath:test.json"
locationInfoEnabled="true"/>
```
Due to #1692, you also need to upgrade to version 2.21.0 or later, since the bug prevents location information from being computed for some method calls.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] JSON layout does not display line numbers (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #2844:
URL: https://github.com/apache/logging-log4j2/issues/2844#issuecomment-2301929799
> I found that the '%X' in the template is invalid.
Yes, `%<something>` pattern converters are not supported in the values of templates.
You need to use:
* either a [`${...}` property substitution expression](https://logging.staged.apache.org/log4j/2.x/manual/json-template-layout.html#property-substitution-in-template)
```json
"traceId": "${ctx:x-my-TraceID}"
```
* or the [`pattern` resolver](https://logging.staged.apache.org/log4j/2.x/manual/json-template-layout.html#event-template-resolver-pattern):
```json
"traceId": {
"$resolver": "pattern",
"pattern": "%X{x-my-TraceID}"
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] JSON layout does not display line numbers (logging-log4j2)
Posted by "youngledo (via GitHub)" <gi...@apache.org>.
youngledo commented on issue #2844:
URL: https://github.com/apache/logging-log4j2/issues/2844#issuecomment-2301239210
Also, can't JSON templates use the 'ThreadContext'?
I found that the '%X' in the template is invalid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org