开发者

How to log stackTrace without throwing the Exception in grails

开发者 https://www.devze.com 2023-01-28 21:56 出处:网络
In certain situations, I\'d like to catch an Exception but still show the Stack Trace in the stackTrace log defined via the Log4J properties in grails. How can I do that?

In certain situations, I'd like to catch an Exception but still show the Stack Trace in the stackTrace log defined via the Log4J properties in grails. How can I do that?

I know I could write it into the "normal" log using log.error myException.stackTrace for开发者_开发问答 example, but I don't want the stack trace to fill up my normal log file.


there is already a stacktrace log generated by grails.

you can get that logger and then add your log statements in the catch block of the exception

LogManager.getLogger("StackTrace")

http://grails.org/doc/latest/guide/3.%20Configuration.html#3.1.2%20Logging

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号