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.

935 questions
18
votes
7 answers

get line number and filename for a log output

Is it possible to get the line number and file for each log output ? For example: var winston = require('winston'); winston.log('info', 'some message!'); // this is at line 4 of myfile.js should specify in log file that 'some message' came…
Lev
  • 13,856
  • 14
  • 52
  • 84
18
votes
4 answers

Add module name in winston log entries

Is there a possibility to save the current module name in order to be printed automatically in winston log entries when they are called later? Currently, when I want to print the module name in logs, I have to add it manually: var logHeader =…
Alexandru Irimiea
  • 2,513
  • 4
  • 26
  • 46
17
votes
1 answer

How can I change the winston log format?

In my node application I'm using winston module to store my application logs. We can store the the logs in two format one is json and the other one is string. While saving the log as string in winston I'm getting below log format. …
sachin
  • 13,605
  • 14
  • 42
  • 55
17
votes
3 answers

Mocha with Node: Only show logging for tests that fail

I'm using node with mocha and winston. Is there a way to set it up so it only shows logs for failing tests?
Koen Bok
  • 3,234
  • 3
  • 29
  • 42
16
votes
5 answers

JavaScript / Jest: How to show logs from test case only when test fails?

I'm working on an end-to-end test suite using selenium where the test cases are written in JavaScript using the jest test runner. My problem is that selenium often fails unceremoniously when something doesn’t work with little explanation to where…
Paul
  • 7,836
  • 2
  • 41
  • 48
16
votes
1 answer

Why are strings passed to winston kept in memory, leaking and ultimately crashing the node.js process?

I'm inspecting a heap snapshot created by node-heapdump@0.3.14, running on Node.js 10.16.0 in Amazon Linux with kernel 4.14.123-86.109.amzn1.x86_64. Heap snapshot is 1GB and, good news, strings visibly consume most of it, using 750MB of both shallow…
15
votes
2 answers

Override console.log|error with winston no longer working

For a while we were using a simple lib to override the default console.log| error with winston, but it no longer works. This is our little module: const path = require('path') const fs = require('fs-extra') const { createLogger, format, transports }…
user1037355
15
votes
2 answers

How to make `winston` logging library work like `console.log`?

The winston library is great for transports and flexibility. I'd like to use it to allow configuring levels and redirecting to files, but would like to reproduce console.log behavior for formatting, and having trouble. Here's what I have so…
DS.
  • 22,632
  • 6
  • 47
  • 54
15
votes
3 answers

How to daily rotate logs using Winston except the first day

I need to rotate the logs daily except the file for current day. I'm using winston and winston-daily-rotate-file libraries. In the following example, a file "info.log.2016-08-09" is generated just the first time I execute node. But, I really need…
larrytron
  • 689
  • 4
  • 11
  • 26
15
votes
3 answers

NodeJS winston log file not change upon size limit

I'm using Winston logging and have specified file size to be max 10MB. { filename: 'e:\app.log', json:false, maxsize:'10MB', maxFiles:'10', timestamp:true, level:'silly' } I'm expecting the app.log file to be rotated…
Lee
  • 2,874
  • 3
  • 27
  • 51
15
votes
5 answers

nodejs winston - Logging with multiple arguments

I was trying to use winston for logging, but I am seeing that if I want to get the data with 2 arg, then I am getting the log, but if I want to get 3 arguments, then I am not getting the data, Ex: logger = new (winston.Logger)({ transports: [ …
user1887432
  • 253
  • 1
  • 3
  • 10
14
votes
2 answers

Winston logger.info is not a function

I've set up Winston with transports to MySQL and console and put it in a module called logger. Like so... // modules/logger.js /* require statements */ exports.logger = new (winston.Logger)({ transports: [ new…
starleaf1
  • 2,701
  • 6
  • 37
  • 66
14
votes
3 answers

Merging stack traces in rethrown errors

I'm rethrowing here an error from Sequelize promise (Bluebird). In the first place, this was done to change error message, but as it appeared, this also produces more informative stack trace. It is something like sequelize.sync().catch(originalError…
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
14
votes
4 answers

Winston not Logging to console in typescript

I am confused by winston. I am using the following typescript code to log onto the console in my *.ts file: import { Logger, LoggerInstance } from "winston"; const logger:LoggerInstance = new Logger(); logger.info('Now my debug messages are written…
wzr1337
  • 3,609
  • 5
  • 30
  • 53
14
votes
1 answer

Winston/Node.js how add a Transport only for certain environment?

I have the follow configuration: var winston = require('winston'); var Mail = require('winston-mail').Mail; var logger = new (winston.Logger)({ transports: [ new (winston.transports.Console)({ level: 'info', colorize: true }), new…
Zauker
  • 2,344
  • 3
  • 27
  • 36
1 2
3
62 63