The file transport writes log messages to a file.
-
appName determines a location of log file, something like
~/.config/<app name>/log.log
depending on OS. By default electron-log reads this value fromname
orproductName
value inpackage.json
. In most cases you should keep default value. -
archiveLog Function (oldLogPath: string) => void which is called on log rotation. You can override it if you need custom log rotation behavior. This function should remove old file synchronously.
-
file - The full log file path. I can recommend to change this value only if you strongly understand what are you doing. If set,
appName
andfileName
options are ignored. -
fileName, default 'log.log'
-
format, default
'[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}] {text}'
-
level, default 'silly'
-
maxSize of log file in bytes, 1048576 (1mb) by default. When a log file exceeds this limit, it will be moved to log.old.log file and the current file will be cleared. You can set it to
0
to disable -
sync Whether to write a log file synchronously. Default to true.
-
writeOptions
- flag, default 'a'
- mode, default 0666
- encoding, default 'utf8'
-
clear() - Clear the current log file
-
findLogPath() - Return full path of the current log file
-
init() - In most cases, you don't need to call it manually. Try to call only if you change
appName
,file
orfileName
property, but it has no effect.