You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Dmitry Holodov (JIRA)" <ji...@apache.org> on 2015/01/27 08:18:35 UTC

[jira] [Commented] (LOG4J2-914) ThrowableProxy.getExtendedStackTraceAsString causes NullpointerException

    [ https://issues.apache.org/jira/browse/LOG4J2-914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14293091#comment-14293091 ] 

Dmitry Holodov commented on LOG4J2-914:
---------------------------------------

Will 2.2 or any version with this fix be released soon?  I'm running into this error too.  The snapshot did fix it for me.

I'm doing UDP logging.  First I tried using the built in UdpSocketServer class, but it doesn't print the stack traces received since they are encapsulated in this ThrowableProxy.  I wrote my own version of the UdpSocketServer to extract the stacktrace using ThrowableProxy. getExtendedStackTrace() and append it to the formatted message, but even that is failing with the bug in this ticket.

Thanks!

> ThrowableProxy.getExtendedStackTraceAsString causes NullpointerException 
> -------------------------------------------------------------------------
>
>                 Key: LOG4J2-914
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-914
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1
>            Reporter: Kaj Bjurman
>            Assignee: Gary Gregory
>            Priority: Minor
>             Fix For: 2.2
>
>
> I'm trying to write a poc with Log4j 2.1, where distributed processes are logging to a remote server. The server is currently running the bundled TcpSocketServer.createSerializedSocketServer with a custom layout plugin. 
> A process is logging an exception. I can then see in the custom layout plugin at the log server that the LogEvent doesn't contain a thrown, but that it contains a thrownProxy. So far so good. I'm then trying to get hold of a String representation of the message + stacktrace. I thought that I would be able to e.g invoke ThrowableProxy.getExtendedStackTraceAsString(), but that causes a NullPointerException since the throwable in the ThrowableProxy also is null after deserialization. Looks like ThrowableProxy assumes that throwable isn't null in a few methods. 
> The exception that is logged by the client process is a simple new Exception("A message");
> The pom.xml that I'm using:
> {code:xml}
> <dependency>
> 	<groupId>org.apache.logging.log4j</groupId>
> 	<artifactId>log4j-api</artifactId>
> 	<version>2.1</version>
> </dependency>
> <dependency>
> 	<groupId>org.apache.logging.log4j</groupId>
> 	<artifactId>log4j-core</artifactId>
> 	<version>2.1</version>
> </dependency>
> <dependency>
> 	<groupId>com.lmax</groupId>
> 	<artifactId>disruptor</artifactId>
> 	<version>3.3.0</version>
> </dependency>
> {code}
> The stacktrace that I get in the server:
> {code}
> 2014-12-05 14:30:44,601 ERROR An exception occurred processing Appender XXXXX java.lang.NullPointerException
> 	at org.apache.logging.log4j.core.impl.ThrowableProxy.getExtendedStackTraceAsString(ThrowableProxy.java:340)
> 	at org.apache.logging.log4j.core.impl.ThrowableProxy.getExtendedStackTraceAsString(ThrowableProxy.java:323)
> {code}
> Workaround:
> To invoke ThrowableProxy. getExtendedStackTrace() and format the stacktrace + message with my own format methods.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org