Questions tagged [winston]

A multi-transport async logging library for node.js.

Winston is designed to be a simple and universal logging library with support for multiple transports. A transport is essentially a storage device for your logs. Each instance of a winston logger can have multiple transports configured at different levels. For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file.

There also seemed to be a lot of logging libraries out there that coupled their implementation of logging (i.e. how the logs are stored / indexed) to the API that they exposed to the programmer. This library aims to decouple those parts of the process to make it more flexible and extensible.

798 questions
107
votes
5 answers

Node.js - logging / Use morgan and winston

we use morgan in order to log our express transformation: var morgan = require('morgan'); morgan('combined'); // a format string morgan(':remote-addr :method :url :uuid'); // a custom function morgan(function (req, res) { return req.method + ' '…
Or Smith
  • 3,178
  • 12
  • 33
  • 60
100
votes
9 answers

How can I add timestamp to logs using Node.js library Winston?

I want to add timestamp to logs. What is the best way to achieve this?
kolrie
  • 11,822
  • 13
  • 57
  • 94
66
votes
11 answers

How to use Winston in several modules?

I have several modules - let's say server.js, module1.js,...,moduleN.js. I would like define the log file in my server.js: winston.add(winston.transports.File, { filename: 'mylogfile.log' }); and then use it in all my modules. What is the best way…
Alexander
  • 6,090
  • 2
  • 44
  • 58
47
votes
1 answer

TypeError: winston.Logger is not a constructor with winston and morgan

I tried with Winston for logger. I used in one project their It's working well when I copy paste the code from their to the current existing project than I face an issue like TypeError: winston.Logger is not a constructor let logger = new…
Gunjan Patel
  • 2,120
  • 3
  • 20
  • 40
44
votes
6 answers

How to Log Full Stack Trace with Winston 3?

My logger is set up like: const myFormat = printf(info => { return `${info.timestamp}: ${info.level}: ${info.message}: ${info.err}`; }); const logger = winston.createLogger({ level: "info", format: combine(timestamp(), myFormat), …
Anthony Xie
  • 449
  • 1
  • 4
  • 6
36
votes
10 answers

How would a human read a json winston log file?

It seems nice for API's, scripts and what not. But reading a winston json stack trace is very hard with a text editor. E.g. {"level":"info","message":"starting","timestamp":"2014-05-14T15:45:44.334Z"} {"date":"Wed May 14 2014 08:45:45 GMT-0700…
ubershmekel
  • 9,570
  • 6
  • 62
  • 78
35
votes
1 answer

Winston Logger - NodeJs Debug console logs not showing in VSCode

I'm using VSCode debugger and winston logger for NodeJS, but can't see output from application unless I specify external terminal like this: "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", …
Josip
  • 864
  • 8
  • 10
34
votes
8 answers

How to log JavaScript objects and arrays in winston as console.log does?

I was looking at top Node logging systems: npmlog, log4js, bunyan and winston and decided to use winston for having the most npm monthly downloads. What I want to set up is custom logger which I will be able to use on development environment with…
Tommz
  • 3,155
  • 7
  • 28
  • 42
33
votes
5 answers

Winston doesn't pretty-print to console

I'm trying to get Winston to pretty print to the console, so I stuck this in a file and ran it with node: var winston = require('winston'); winston.cli(); winston.data({ a: "test", of: "many", properties: { like: "this" …
JoBu1324
  • 7,633
  • 6
  • 40
  • 59
32
votes
8 answers

Disable winston logging when running unit tests?

Can Winston logging be selectively disabled when executing unit tests of a node module? Ideally, I'd like to have logging for informational and debug purposes when the application is running, but be suppressed as to not clutter the presentation…
Sk606
  • 1,724
  • 1
  • 18
  • 14
30
votes
3 answers

winston:how to change timestamp format

I am using winston to add log details in node.js, i used the following procedure to add the logs var winston = require('winston'); winston.remove(winston.transports.Console); winston.add(winston.transports.Console,…
Amanda G
  • 1,663
  • 7
  • 31
  • 41
29
votes
5 answers

How to set log level in Winston/Node.js

I am using Winston logging with my Node.js app and have defined a file transport. Throughout my code, I log using either logger.error, logger.warn, or logger.info. My question is, how do I specify the log level? Is there a config file and value that…
Silent User
  • 2,357
  • 4
  • 26
  • 33
26
votes
7 answers

Much needed: well-highlighted JSON log viewer

Using winston for node.js logging, I get json log files. A log file in this vein is simply a sequence of (newline delimited) json objects. This is great for log querying and treating logs as first-class data! However, both Sublime and gedit (at…
matanster
  • 13,785
  • 14
  • 75
  • 135
25
votes
5 answers

How do I change my node winston JSON output to be single line

When I create a nodejs winston console logger and set json:true, it always output JSON logs in multiline format. If I pipe these to a file and try to grep that file, my grep hits only include part of the log line. I want winston to output my log…
zayquan
  • 5,280
  • 2
  • 25
  • 35
20
votes
5 answers

How to flush winston logs?

I want to flush the winston logger before process.exit. process.on('uncaughtException', function(err){ logger.error('Fatal uncaught exception crashed cluster', err); logger.flush(function(){ // <- process.exit(1); }); }); Is…
bevacqua
  • 43,414
  • 51
  • 157
  • 277
1
2 3
53 54