When winston handles uncaught exceptions it prints a nice info of the uncaught exception.How can I do the same on "catched exceptions"?
if (err) {
// winston. log the catched exception
}
I checked the source and there seems to be a logException
method but I don't know how I could use it.
var logger = new winston.Logger({
transports: [new winston.transports.Console({handleExceptions: true})]
})
var err = new Error('test error.')
logger.logException(err.message) //no method 'logException'
Unless you are going to change the exception, you should only log at the level where you are going to handle the error and not rethrow it. Otherwise your log just has a bunch of "noise", 3 or more of the same message logged, once at each layer.
Click System administration > Periodic > Services and Application Integration Framework > Exceptions. On the Overview tab, select an exception record. Click the General tab to view additional details about the exception.
To log a handled exceptionCreate the method that will generate the exception information. Use a Try...Catch block to catch the exception. Put the code that could generate an exception in the Try block. Uncomment the Dim and MsgBox lines to cause a NullReferenceException exception.
Ideally you should log the stack trace provided by the exception, or throw the exception and log the event further up the stack.
You can emit catched exception back to process, error will by catched by winston.Logger. Example:
process.emit('uncaughtException', err);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With