What is the default location of Winston logs?
Asked Answered
S

3

6

I am using something like this:

var winston = require('winston'), logger = new (winston.Logger)({
  transports: [
    new (winston.transports.Console) (),
    new (winston.transports.File) ({filename: 'test.log'})
  ]
});

logger.log('Hello world');

I cannot find the log file test.log anywhere on my system and no exception or info in the console either.

Squint answered 3/8, 2012 at 22:10 Comment(0)
S
9

Nevermind, I found the answer. If you do not specify directory, it is in the same directory as the code.

Squint answered 5/8, 2012 at 1:40 Comment(1)
or rather root of the project.Adjutant
K
1

Paste the following snippet in your winston.helper.js

// create directory for logs first
if (!fs.existsSync("logs")) {
    fs.mkdirSync("logs");
}

OR

You can write a command in your package.json script For e.g.

"dev": "mkdir logs | ..."
Katzenjammer answered 17/1, 2019 at 6:58 Comment(0)
V
0

set the route of the file name like this '${__dirname}/filename' if this not working change the colon into back quote

Ventilation answered 12/12, 2018 at 13:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.