You can continue to use some older version or migrate to the latest. Here are documentation and code snapshot for older releases: v2, v3.
If you would like to upgrade to the latest version, check the changelog and migration guide below.
npm install electron-log@latest
If you just use electron-log with default configuration, you only need to know that a default log file path was changed.
-
Default log path was changed on Linux and Windows to be more compatible with
app.getPath('logs')
of Electron:~/.config/{app name}/log.log →
~/.config/{app name}/logs/{process type}.log
%USERPROFILE%\AppData\Roaming\{app name}\log.log →
%USERPROFILE%\AppData\Roaming\{app name}\logs\{process type}.log
If you need to keep old file paths, you can override
file.resolvePath
-
file.fileName
is nowmain.log
,renderer.log
orworker.log
depending on process type -
new option
file.resolvePath
allows overriding default log path. Here is default implementation:log.transports.file.resolvePath = (variables) => { return path.join(variables.libraryDefaultDir, variables.fileName); }
- new method
file.getFile()
was added. It allows to manipulate the current log file.
- new method
-
The following file transport options and methods are deprecated and will be removed in v5:
file.file
, usefile.resolvePath
insteadfile.bytesWritten
, usefile.getFile().bytesWritten
insteadfile.fileSize
, usefile.getFile().size
insteadfile.clear()
, usefile.getFile().clear()
insteadfile.findLogPath()
, usefile.getFile().path
insteadfile.init()
, doesn't matter anymore
If you change some options of these transport, just use the same options of
ipc
transport instead.
npm install electron-log@latest
In v3 each process is configured separately. So if you change some options, you should apply the changed both in main and renderer processes.
Another changes:
- require
electron-log/main
andelectron-log/renderer
is deprecated. transports.file.level
is default to 'silly'.transports.file.stream
andstreamConfig
options are removed. Instead, you can use one of the following options:file
,fileName
,writeOptions
.rendererConsole
andmainConsole
transports are disabled by default for a packaged application.