Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron app - logging to file in production

I want to get logs if something wrong happens to my electron app when in production mode i.e after giving .exe file to a user wrt windows platform.

How to go about it, how can i basically write my errors to a file which will be in cyclic in nature.

like image 776
Anuj Nautiyal Avatar asked Jan 07 '17 14:01

Anuj Nautiyal


1 Answers

Take a look at electron log

// Setup file logging
const log = require('electron-log');
log.transports.file.level = 'info';
log.transports.file.file = __dirname + 'log.log';

// Log a message
log.info('log message');

EDIT:

As mentioned in the comments the "log.transports.file.file" is deprecated.

Instead I would suggest to use the following method.

log.transports.file.resolvePath = () => __dirname + "/log.log";
like image 104
syonip Avatar answered Sep 22 '22 08:09

syonip