Open ComLock opened 4 years ago
@rymsha any suggestions? has to be implemented?
This is a documentation issue. https://github.com/enonic/doc-xp/blob/master/docs/framework/globals.adoc#log
The trick is to provide two arguments where second one is an exception instance:
try {
bean.run();
} catch (e) {
log.info('Red Alert!', e)
}
@anatol-sialitski document it, please, since you implemented this improvement.
So you're saying that if I do:
log.debug(e); There's no stacktrace in the log
But if I do log.debug('', e); Then I get the stacktrace?
Yes, by the idea you should be able to log stacktrace if second parameter will be passed as an error/exception.
What if I want to store the stacktrace in a variable and write it to a Enonic XP node so I can debug errors later? Still sure this is a documentation issue?
You should never store error stack-traces in XP (imagine what might happen), if you intend to store them anywhere, write them to logs.
Currently I know of no way to log a stacktrace and continue. Please document how, or make it possible ? :)
Related: https://discuss.enonic.com/t/catch-specific-java-errors-in-javascript/928/3