question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why set log.transports.file.file doesn't work?

See original GitHub issue

Hello.

In my project(use electron & vue), I configure the transport formats in main.js like this.

```
const logFormat = '{h}:{i}:{s}:{ms} {text}'
log.transports.console.format = logFormat
log.transports.console.format = (msg) => util.format.apply(util, msg.data);

const appDataDir = path.join(app.getPath('appData'), 'my-project')
log.transports.file.level = 'info'
log.transports.file.format = logFormat
log.transports.file.maxSize = 5 * 1024 * 1024
log.transports.file.file = path.join(appDataDir, 'log.log')
log.transports.file.streamConfig = { flags: 'w' }
log.transports.file.stream = fs.createWriteStream('log.log')

1. This works in dev mode, except the log file does not in the path of configuration(appDataDir/log.log), but the project folder in my desktop.

2.When I build my app with electron builder and run, it shows me an error of 
"**Uncaught Exception:
Error: EACCES: permission denied, open 'log.log**'"

Am I wrong with something? How can this be fixed please.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
megahertzcommented, Oct 26, 2017

In most cases, the application directory is not writable after installation. That’s why default log path is inside appData directory. I think it’s not very easy to make it writable on windows, and it’s impossible on linux and mac.

0reactions
megahertzcommented, Nov 1, 2017

no problem)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron app - logging to file in production - Stack Overflow
Take a look at electron log // Setup file logging const log = require('electron-log'); log.transports.file.level = 'info'; ...
Read more >
[Electron][TypeScript] output/input files - DEV Community ‍ ‍
So if I execute "log.transports.file.resolvePath" only in "main.ts", the logs of "preload.ts" are saved in "C:/Users/ ...
Read more >
electron-log | Yarn - Package Manager
Transport. Transport is a simple function which does some work with log message. By default, two transports are active: console and file. If...
Read more >
Winston - Best of JS
Note that the default logger doesn't have any transports by default. ... File({ filename: 'combined.log' }); const console = new winston.transports.
Read more >
How to use the electron-log.transports function in ... - Snyk
To help you get started, we've selected a few electron-log.transports examples, ... store'; // Set level log.transports.file.level = 'debug'; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found