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
14
votes
5 answers

Cannot find module 'winston'

I wrote a little module that uses winston to log stuff. I used sudo npm install -g winston (it is on a vm...so i'm not too concerned with sudo, etc. Log from npm: winston@0.7.2 /usr/local/lib/node_modules/winston ├── cycle@1.0.2 ├──…
hba
  • 7,406
  • 10
  • 63
  • 105
13
votes
8 answers

Invalid transport, must be an object with a log method winston mongodb logging

I want to store my error logs in mongoDB collection. I am using winston & winston -mongoDB. Getting the error: throw new Error('Invalid transport, must be an object with a log method.'); Error: Invalid transport, must be an object with a log …
saurabh ujjainwal
  • 153
  • 1
  • 1
  • 5
13
votes
3 answers

Is it possible to use winston logging and debug module together?

I use winston logging because I use its features like different logging levels, multiple transports, etc. But I also like debug's namespace feature. Besides, express already uses it. So is it possible to use them together, e.g. to let winston…
Qiulang
  • 10,295
  • 11
  • 80
  • 129
13
votes
4 answers

How to log "catched" exceptions?

When winston handles uncaught exceptions it prints a nice info of the uncaught exception.How can I do the same on "catched exceptions"? if (err) { // winston. log the catched exception } I checked the source and there seems to be a logException…
Jürgen Paul
  • 14,299
  • 26
  • 93
  • 133
12
votes
5 answers

How to force nodejs winston log to file before process exit

I am using winston 3 to log my data. But sometimes it didn't log the error before process exit. The following process will exit, without log to the logfile.log: const winston = require('winston'); winston.add(new winston.transports.File({ …
Wan Chap
  • 841
  • 7
  • 13
12
votes
4 answers

AWS Lambda using Winston logging loses Request ID

When using console.log to add log rows to AWS CloudWatch, the Lambda Request ID is added on each row as described in the docs A simplified example based on the above mentioned doc exports.handler = async function(event, context) { …
12
votes
4 answers

How are you supposed to create Winston logger stream for Morgan in TypeScript

What is the correct way to create a winston logger in TypeScript that will log the express Morgan middleware logging? I found a number of JavaScript samples but have had trouble converting them over to TypeScript, because I get an error Type '{…
JoAMoS
  • 1,459
  • 3
  • 18
  • 27
12
votes
2 answers

Winston: Attempt to write logs with no transports

I'm trying to set up an access log and an error log for my express server using Winston, but I seem to be doing something wrong. Here is my attempt at a config file: const winston = require('winston'), fs = require('fs'); const tsFormat = () =>…
user2771142
  • 123
  • 1
  • 1
  • 5
12
votes
1 answer

Is winston logging framework is truly Async

I am developing a logging framework using winston in nodejs , I had check that winston using Async module , but I need to verify whether it is truly Async nature or not. Please suggest.
Indrani Sen
  • 287
  • 4
  • 19
11
votes
3 answers

Can Winston Logger be used on the front-end for logging?

I am creating full mean stack app with NodeJs , Angular 6 , ExpressJs and MongoDB I have managed to create a server and its working perfectly, instead of using console.log when logging errors in my app I have decided to use Winston Logger here…
The Dead Man
  • 6,258
  • 28
  • 111
  • 193
11
votes
5 answers

How to add uuid in every winston log node js per request?

I am using winston logger. I want to add uuid in every logs having same uuid per request. In app.js var distributorapp = require('./routes/distributorapp'); app.use('/dstapp',distributorapp); In routes/distributorapp.js(Middleware) var qs =…
udgeet patel
  • 439
  • 1
  • 7
  • 23
11
votes
1 answer

Node.js Winston logging - exitOnError

I'm a little confused on what exactly this means. There is an "explanation" on the github page for Winston, that says you can exit, or not exit. Does that mean that the Winston object dies or stays, or that the node.js process dies or stays? Or…
CargoMeister
  • 4,199
  • 6
  • 27
  • 44
10
votes
2 answers

winston saves color formatter in text, how to remove this but still show color?

I am trying to create a logging module using winston as the logging framework. It allows me to specify colors, which is quite nice if the transport is Console, but if I were to define two transports, one Console, one File, it will actually save the…
PGT
  • 1,468
  • 20
  • 34
10
votes
1 answer

Logging with winston-mongodb and express-winston

I'm trying to log request/response into MongoDB within NodeJS project using express-winston and winston-mongodb. Here is an example code that I worked so far; const expressWinston = require('express-winston'); const winston = require('winston');…
josh
  • 409
  • 1
  • 5
  • 18
10
votes
2 answers

How to delete files from winston log after certain days limit?

I am using winston to log files into server that is working as expected , now i want to set days limit , Lets say after 3 days i want to delete files that are logged 3 days ago , is it possible to achieve using winston rotation ? main.js …
hussain
  • 6,587
  • 18
  • 79
  • 152