How to log exceptions to file in production


My Electron app works fine on my Mac, but an end-user is facing a weird startup bug. Electron shows this message, which is not very helpful:


So I was looking for a way to log all exceptions to a file, but could not find a solution.

Is there a preferred way of logging such kind of errors to a file, e.g. in the application’s working directory under “Application Support”?

I am also wondering if there’s a way to intercept all exceptions and use a custom dialog instead.


I don’t have an answer for you, but you might want to include your version of Mac, your user’s version, and the version of Electron you’re using, just in case that information is relevant to the people who have more knowledge.


Thanks for your reply.

Actually, I was just able to find the root cause, it was an unhandled exception in a 3rd party library.

But my question still remains: Is it possible somehow to route all console logs and exceptions to a file.

So far, I found

  • electron-log which allows to route explicit logs to a file
  • process.on('unhandledException'), but this would require me to implement yet another file logger on my own
  • electron-undhandled which allows to catch unhandled exceptions and route them to the console or a dialog; but this still would require setting up an own file log
  • electron-timber which allows to log renderer messages to the main process (or to a stream)

I was looking for a darn simple way to route the console to a file in a standard folder, no matter where the errors actually come from.