How to print out the debug log of the entire call chain when sending an exception.

in the process of WEB development, for example, when a runtime exception occurs in the Dao layer, the exception information can be captured and printed in the WEB exception handler. However, when requesting to which Dao layer, it is assumed that there are corresponding DEBUG logs in each method. If you can better and gracefully allow the exception, record all the DEBUG logs before the exception, instead of just recording the context information of the current exception method. But the DEBUG information of the entire request call chain is also printed?

find a similar question in CSDN, but to get an answer.

how can I print out the above debug log when an exception occurs?

Mar.21,2021

I don't know if I understand it correctly, but there are a lot of log.debug (.) in the call chain, and your log level is info normally this log is not printed to the log file. Your hope is to output all the debug level logs on the call chain when an exception occurs.

this is more difficult to achieve. I think it is just to locate the problem. There are some methods to dynamically adjust the log level, which is set to info when there is a lot of online traffic, and to debug when you need to debug the problem, and then change back to info

after debugging.

refer to
https://tech.meituan.com/chan.

.

can only provide so much information, and I am more concerned about this problem. It would be much better to troubleshoot the problem if I could implement the problem described above.

Menu