Bug: Logs are blank in Sentry breadcrumbs
Describe the bug
Here's what tslog looks like in Sentry breadcrumbs with pretty logging:

This is captured to sentry in Node like this:
} catch (error) {
Sentry.captureException(error)
throw error
}
Not sure what the core issue is 🤷
Expected behavior Pretty logs would show up correctly
Update: I'm now using JSON logs but they are still blank in Sentry
Interesting. Would you share how you integrated Sentry?
This is how I did it (through transports)
// Sentry
if (this.logConfig.isSentryEnabled) {
Sentry.init({
dsn: this.logConfig.sentryDsn,
maxBreadcrumbs: this.logConfig.sentryMaxBreadcrumbs,
debug: this.logConfig.sentryDebug,
serverName: hostname(),
tracesSampleRate: this.logConfig.sentryTracesSampleRate,
environment: process.env.NODE_ENV,
release: `${process.env.npm_package_name}@${process.env.npm_package_version}`,
integrations: [
// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true })
]
});
loggerFactory.logger.attachTransport(
{
silly: this.logToSentry,
debug: this.logToSentry,
trace: this.logToSentry,
info: this.logToSentry,
warn: this.logToSentry,
error: this.logToSentry,
fatal: this.logToSentry
},
this.logConfig.sentryMinLevel
);
}
and
private logToSentry = async (logObject: tslog.ILogObject) => {
// send only exceptions to Sentry
logObject?.argumentsArray?.forEach((argument: tslog.IErrorObject) => {
if (argument.isError === true) {
Sentry.captureException(argument.nativeError);
}
});
};
@terehov I did not use any special integration, am just relying on Sentry's automatic pickup of console.log.
That is definitely interesting, but would be nice if it could just work without that.
@flybayer Were you able to find a workaround for this? I like and could use @terehov's solution but it is a bit hacky.
In V4 I am going to use consoleper default, rather than Stdout. I believe that should be more compatible with Sentry per default.
As mentioned before, V4 uses console per default (can be overwritten though) and is even more flexible and allows overwriting every part of the log processing. Give it a go and let me know if that solves your problem:
-
npm i tslog@next -
and run it with
node --enable-source-mapsor for TypeScriptnode --enable-source-maps --experimental-specifier-resolution=node --no-warnings --loader ts-node/esm
Thank you.
V4 is released now, so I'm going to close this issue. Feel free to open a new one if V4 didn't solve it for you.
Here are the docs: tslog.js.org