apache / apache/logging-log4j2

Uniformise `%ex` pattern and `exception` JTL resolver

Open
#3,623 0 comments 1 reaction 1 assignee Claimed by @vy View on GitHub
bug layouts
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

## Description

Currently there is a difference in the way exceptions are formatted by the [`%ex` pattern converter](https://logging.apache.org/log4j/2.x/manual/pattern-layout.html#converter-exception) and the following [JSON Template Layout snippet](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#event-template-resolver-exception):

```json
{
"$resolver": "exception",
"field": "stackTrace",
"stackTrace": {
"stringified": true
}
}
```

- JTL simply uses `Throwable.printStackTrace()` and the first line of the output is obtained by calling `Object.toString()`.
- Pattern Layout uses `getClass().getName() + ": " + getLocalisedMessage()`.

Those lines agree, unless an exception overrides `Object#toString()`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.