[logback-user] 回复: logback does not print exception's cause

陌路人 h5ru at qq.com
Thu Jun 18 08:25:51 CEST 2020


Hi Jörn,
Thank you a lot a lot :) :) I will try it:)

BR,
Mike(Yu, Chong-Chao)


 




------------------ 原始邮件 ------------------
发件人: "Jörn Huxhorn"<jhuxhorn at googlemail.com>;
发送时间: 2020年6月14日(星期天) 晚上10:42
收件人: "logback users list"<logback-user at qos.ch>;

主题: Re: [logback-user] logback does not print exception's cause



 Hi Mike,


sorry for the late answer. I hope this still helps you.


This stackoverflow answer solves your problem:
https://stackoverflow.com/questions/2411487/nullpointerexception-in-java-with-no-stacktrace#3010106


TL;DR:
You are running into a hotspot optimisation and need to add -XX:-OmitStackTraceInFastThrow to your JVM options to “enable” those stacktraces.
 

Cheers,Jörn.
 
 

On 10. June 2020 at 04:52:38, 陌路人 (h5ru at qq.com) wrote:
 
Hi,
Firstly thank you for your time.
Sometimes, logback does not print exception's cause, I can't use the log to fix bug, as followings:


2020-06-09 16:54:32,393 ERROR [task-executor-27] [SimpleDispatcher.java:203] Exception occurred during dispatch web socket frame for uri[/ws/partydungeon/move] by uid[‪6493203‬].
java.lang.reflect.InvocationTargetException: null
	at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.mitu.game.dispatcher.SimpleDispatcher$EventRunnable.doWebSocketMessage(SimpleDispatcher.java:187)
	at com.mitu.game.dispatcher.SimpleDispatcher$EventRunnable.run(SimpleDispatcher.java:106)
	at com.mitu.game.wrapper.ThreadPoolTaskExecutorEx$SafeRunnable.run(ThreadPoolTaskExecutorEx.java:74)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: null
2020-06-09 16:54:32,405 INFO [nioEventLoopGroup-3-4] [SimpleLoggingHandler.java:35] IN {uid=‪5589867‬, forward=183.200.25.192, 183.200.25.192:24172, type=websocket, uri=/ws/user/bind, ts=‪1591692869‬} /10.0.0.70:34948 10



And the code is like:
    private void doWebSocketMessage(Event event) {
            String uri = "some uri";
            String uid = "some id";
            try {
                Object ret = action.method.invoke(action.instance, event.getData(), new Object[]{event});
            } catch (Exception ex) {
                logger.error(String.format("Exception occurred during dispatch web socket frame for uri[%s] by uid[%s].", uri, uid), ex);
            }
        }



I tried to look for answers by google and bing, but failed, and I tried to reproduce this problem, failed too, the cause can be printed, and it likes:
java.lang.reflect.InvocationTargetException: null
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.mitu.game.Application.main(Application.java:54)
Caused by: java.lang.NullPointerException: null
	at com.mitu.game.Application$T.f(Application.java:42)
	... 5 common frames omitted 


the difference is NativeMethodAccessorImpl vs GeneratedMethodAccessor100, is it matter? I steped into the logback code, maybe the target of the exception is null, but I do not know the reason:(




Thank you again, for your patient, and sorry for my poor english:(

BR,Mike Yu

_______________________________________________
logback-user mailing list
logback-user at qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20200618/6fbd332b/attachment-0001.html>


More information about the logback-user mailing list