How to register stackTrace without throwing an exception in grails

In some situations, I would like to get an exception, but still show the stack trace in the stackTrace log defined using the Log4J properties in grails. How can i do this?

I know that I can write it to a "normal" log using log.error myException.stackTrace, for example, but I do not want the stack trace filling my regular log file.

+3
source share
1 answer

there already exists a stacktrace log generated by grails.

you can get this logger and then add your log statements to the catch block of the exception

LogManager.getLogger("StackTrace")

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

+3

Source: https://habr.com/ru/post/1778777/


All Articles