开发者

How to log stackTrace without throwing the Exception in grails

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜