Problem: Logs logged with the electron-log module do not show up as sentry breadcrumbs.
I’ve recently upgraded my electron project on different aspects (node version, electron version, electron-builder version) and also switched from using @sentry/node to @sentry/electron SDK for capturing events in main. Before that the logs were included in the breadcrumbs automatically – now, they aren’t. I’ve tried falling back to the previously used node version, electron version, and used @sentry/node – but none of them makes it work again. So I’m missing a hint where to look at.
I’ve read all the documentation for sentry’s node and electron SDKs and cannot find any hint how to achieve this besides from calling addBreadcrumb through the logger by myself. But as it worked before, I think the functionality must be there already and I’m just missing something.
I have a quite simple log and sentry setup:
import * as sentry from '@sentry/electron'; // in renderer I use the same
import log from 'electron-log/main'; // in renderer I import from /renderer of course, in some modules just electron-log itself
const MY_LOGFILE = "myApp.log";
log.transports.file.fileName = MY_LOGFILE;
log.transports.file.level = 'debug';
log.transports.file.resolvePathFn = () => path.join(workingDir, MY_LOGFILE);
sentry.init({
dsn: 'https://...';
beforeSend: (event, hint) => {
...
}
});
sentry.setUser({ id: userId, email: userEmail });
log.debug('my log message'); // this will not show up in breadcrumbs of sentry event
sentry.captureMessage('my sentry message');
The logging into the file and actual console works. If I run the app from terminal, console logs are there.
Only “special” thing I have is a beforeSend implementation that drops some kind of events. But I don’t believe this is anyhow causing the problem.
Only thing I always see in breadcrumbs are console logs called with console.log()
(from renderer) and automated logs like ui clicks, powerMonitor, etc.
What could be the reason the normal logs are not added to the breadcrumbs?
Where could I find a hint?
(Versions currently used: node: v20.9.0, “electron-log”: “^5.1.0”, “electron”: “^29.1.0”, “electron-builder”: “24.12.0”, “@sentry/electron”: “^4.1.0”)
mtba is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.