You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ppkarwasz (via GitHub)" <gi...@apache.org> on 2023/07/31 09:17:21 UTC
[PR] Adapt ExtendedStackTraceElement to Java 9+ (logging-log4j2)
ppkarwasz opened a new pull request, #1641:
URL: https://github.com/apache/logging-log4j2/pull/1641
Closes #1640.
This PR provides a JDK 9+ version of `StackTraceElement` and `ExtendedStackTraceElement` formatting and serialization. The formatting of these elements resembles the one used natively by the JDK:
```
(<classloader>/)?(<moduleName>(@<moduleVersion>)?/)?<formatting as in JDK 8>
```
The names of the builtin classloaders ("app", "boot", "platform") are omitted, as well as the versions of the built-in modules (unless reflective access to `jdk.internal.module` is forbidden) .
To test this PR, run `./mvnw verify -Pjava9-tests`. Some unrelated test failures are to be expected.
--
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: [PR] Adapt ExtendedStackTraceElement to Java 9+ (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #1641:
URL: https://github.com/apache/logging-log4j2/pull/1641#issuecomment-1658113030
After this PR a sample stacktrace changes from:
```
java.lang.RuntimeException: null
at eu.copernik.log4j.test.XmlTest.logError(XmlTest.java:18) ~[classes/:?]
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736) [?:?]
at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728) [?:?]
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) [?:?]
at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) [?:?]
at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) [?:?]
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) [?:?]
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) [?:?]
```
to
```
java.lang.RuntimeException: null
at eu.copernik.log4j.test@1.0.0/eu.copernik.log4j.test.XmlTest.logError(XmlTest.java:18) ~[classes/:?]
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736) [?:?]
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728) [?:?]
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) [?:?]
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) [?:?]
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) [?:?]
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) [?:?]
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) [?:?]
```
--
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: [PR] Adapt ExtendedStackTraceElement to Java 9+ (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #1641:
URL: https://github.com/apache/logging-log4j2/pull/1641#issuecomment-1658118362
A sample XML event passes from:
```xml
<Event xmlns="http://logging.apache.org/log4j/2.0/events" timeMillis="1690800041924" thread="ForkJoinPool.commonPool-worker-19" level="INFO" loggerName="eu.copernik.log4j.test.XmlTest" endOfBatch="false" loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="15" threadPriority="5">
<Instant epochSecond="1690800041" nanoOfSecond="924573100"/>
<Message>Hello world!</Message>
<Source class="eu.copernik.log4j.test.XmlTest" method="logError" file="XmlTest.java" line="19">
<classLoaderName xmlns="">app</classLoaderName>
<moduleName xmlns="">eu.copernik.log4j.test</moduleName>
<moduleVersion xmlns="">1.0.0</moduleVersion>
</Source>
<Thrown commonElementCount="0" name="java.lang.RuntimeException">
<ExtendedStackTrace>
<ExtendedStackTraceItem class="eu.copernik.log4j.test.XmlTest" method="logError" file="XmlTest.java" line="18" exact="false" location="classes/" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.CompletableFuture$AsyncRun" method="run" file="CompletableFuture.java" line="1736" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.CompletableFuture$AsyncRun" method="exec" file="CompletableFuture.java" line="1728" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinTask" method="doExec" file="ForkJoinTask.java" line="290" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinPool$WorkQueue" method="topLevelExec" file="ForkJoinPool.java" line="1020" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinPool" method="scan" file="ForkJoinPool.java" line="1656" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinPool" method="runWorker" file="ForkJoinPool.java" line="1594" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem class="java.util.concurrent.ForkJoinWorkerThread" method="run" file="ForkJoinWorkerThread.java" line="183" exact="true" location="?" version="?"/>
</ExtendedStackTrace>
</Thrown>
</Event>
```
to
```xml
<Event xmlns="http://logging.apache.org/log4j/2.0/events" timeMillis="1690800122073" thread="ForkJoinPool.commonPool-worker-19" level="INFO" loggerName="eu.copernik.log4j.test.XmlTest" endOfBatch="false" loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="17" threadPriority="5">
<Instant epochSecond="1690800122" nanoOfSecond="73385600"/>
<Message>Hello world!</Message>
<Source classLoaderName="app" moduleName="eu.copernik.log4j.test" moduleVersion="1.0.0" class="eu.copernik.log4j.test.XmlTest" method="logError" file="XmlTest.java" line="19"/>
<Thrown commonElementCount="0" name="java.lang.RuntimeException">
<ExtendedStackTrace>
<ExtendedStackTraceItem classLoaderName="app" moduleName="eu.copernik.log4j.test" moduleVersion="1.0.0" class="eu.copernik.log4j.test.XmlTest" method="logError" file="XmlTest.java" line="18" exact="false" location="classes/" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.CompletableFuture$AsyncRun" method="run" file="CompletableFuture.java" line="1736" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.CompletableFuture$AsyncRun" method="exec" file="CompletableFuture.java" line="1728" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinTask" method="doExec" file="ForkJoinTask.java" line="290" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinPool$WorkQueue" method="topLevelExec" file="ForkJoinPool.java" line="1020" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinPool" method="scan" file="ForkJoinPool.java" line="1656" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinPool" method="runWorker" file="ForkJoinPool.java" line="1594" exact="true" location="?" version="?"/>
<ExtendedStackTraceItem moduleName="java.base" moduleVersion="11.0.14.1" class="java.util.concurrent.ForkJoinWorkerThread" method="run" file="ForkJoinWorkerThread.java" line="183" exact="true" location="?" version="?"/>
</ExtendedStackTrace>
</Thrown>
</Event>
```
The JSON and YAML layouts undergo similar changes.
--
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: [PR] Adapt ExtendedStackTraceElement to Java 9+ (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz merged PR #1641:
URL: https://github.com/apache/logging-log4j2/pull/1641
--
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