winston

cappedMax not working in winston-mongodb logger in Node.js on Ubuntu

亡梦爱人 提交于 2019-12-12 03:36:58
问题 I have created a logger in Node.js using the winston module and added MongoDB transport by requiring winston-mongodb module with the following options: { db: config.db[k.DB_ENV.AUTHOR], username: config.dbUser, password: config.dbPassword, collection: 'log-aggregation', storeHost: true, capped: true, cappedMax: 10 // documents } I expect the logger to create a new collection for every 10 documents . But the logger continue logging in the same collection. I commented the collection: 'log

Can we specify exact which level winston to log?

こ雲淡風輕ζ 提交于 2019-12-12 02:12:33
问题 I have a logger of winston below. when I try to debug my app. However when I debug my logs, all my screen gets filled with 'error' level. All my useful logs I have put into 'info'. Is there a way that I can only checking only my 'info' level logs? var logger = new (winston.Logger)({ transports: [ new (winston.transports.Console)({ 'timestamp': true, level: "info" }) ] }); 回答1: You can use this handy fork of winston (the downside is that it was forked 3 years ago and doesn't seem to be

Logentries with Winston in not capturing ERROR, DEBUG

橙三吉。 提交于 2019-12-11 19:08:18
问题 I am using Winston 3.1.0 in my NodeJS app, together with Logentries le_node 1.8.0. Logentries is only capturing only INFO, DEBUG nor ERROR nor DEBUG. I am using also Console & File transports, and those are logged correctly. Any idea why LE is only capturing info, debug ? 回答1: Solved by defining levels in constructor: 来源: https://stackoverflow.com/questions/54945706/logentries-with-winston-in-not-capturing-error-debug

How to create multiple log files and append logs in that file using winston library

别来无恙 提交于 2019-12-11 18:56:55
问题 I am using Winston library in nodes for error logs. Now what I want is to create multiple logger files dynamically. The code I am using is this const fs = require("fs"); const winston = require("winston"); const logDir = "log"; if (!fs.existsSync(logDir)) { fs.mkdirSync(logDir); } const tsFormat = () => (new Date()).toLocaleTimeString(); module.exports = logger = winston.createLogger({ transports: [ new (winston.transports.Console)({ format: winston.format.combine( winston.format.colorize(),

how to pass a filename to winston logger?

六眼飞鱼酱① 提交于 2019-12-11 12:25:53
问题 I have winston set up as a logger and it works great. However, I have several processes that I would like to log to different files. How can I pass the filename into a logger instance? I am using this as my block 'use strict'; const { createLogger, format, transports } = require('winston'); require('winston-daily-rotate-file'); const fs = require('fs'); const path = require('path'); const logDir = '/codeforge/log'; const dailyRotateFileTransport = new transports.DailyRotateFile({ filename: `$

dynamically change log level in winston

余生颓废 提交于 2019-12-11 12:15:18
问题 I try to achieve log level change at run time. i have been following https://github.com/yannvr/Winston-dynamic-loglevel/blob/master/test . while calling update function it doesn't change actual transport level setting. e.g i updated to info level but info related log doesn't print in file. it seems doesnt work what it says is there any other way to achieve it.i have come across using setLevel provide by winston but i dont know how to call it from out side to change log level at run time? 回答1:

Winston logger - Is it possible to log the shut down of an application

*爱你&永不变心* 提交于 2019-12-11 06:44:33
问题 In Winston logger for node js, is it possible to log the shut down of a node application? For example, if a node app is run in a docker, and the docker container is killed, is it possible to log that with winston? Or do I need to log it through docker? 回答1: You can capture signal events in node.js and run any code on that signal, in your case the logging. SIGTERM - a graceful shutdown in nodejs A docker stop will send a SIGTERM signal, and that's the standard 'close all your files and

Plain file logging in winston

只谈情不闲聊 提交于 2019-12-11 03:58:21
问题 I want to log just the data and not log level, timestamp etc. to a file. var logger = new (winston.Logger)({ transports: [ new (winston.transports.File)({ filename: '/tmp/data.log', json : false, timestamp : function() { return ''; } }) ] }); logger.log('info', "a") It removes the timestamp from the line but log level still appears. Currently, file contains "info: a". I want it to log just "a". Is it possible to specify output format in winston? 回答1: Unfortunately, that formatting is sort of

node.js express-winston errorLogger skip doesn't work

℡╲_俬逩灬. 提交于 2019-12-11 03:34:21
问题 I'm using node.js with express-winston for logging, like that: var express = require('express'); var app = express(); var winston = require('winston'); var expressWinston = require('express-winston'); var routes = require('./routes/index'); app.use("/", routes); app.use( expressWinston.errorLogger({ transports: [ new winston.transports.DailyRotateFile({ name: 'file', datePattern: '_dd-MM-yyyy.log', colorize: true, json: true, filename: './logs/errors/error_log', maxsize: 50 * 1024 * 1024,

In winston for Node.js is there a way to suppress log level from message?

早过忘川 提交于 2019-12-11 02:23:54
问题 I'm using winston to stream log messages from Express based on various comments elsewhere, my setup is essentially: var express = require("express"), winston = require("winston"); // enable web server logging; pipe those log messages through winston var requestLogger = new (winston.Logger)( { transports: [ new (winston.transports.File)( { filename: "logs/request.log", json: false, timestamp: false } ) ] } ), winstonStream = { write: function(message, encoding) { requestLogger.info(message