morgan

Nodejs - How to use morgan with debug

◇◆丶佛笑我妖孽 提交于 2020-01-01 17:10:33
问题 Morgan outputs requests directly to the console. How can I redirect them to npm debug so that it follows the same format as the other stuff which is being logged? My debug.js config looks like the following: import debug from 'debug'; const LOG_PREFIX = 'api'; const info = debug(`${LOG_PREFIX}:info`); const dev = debug(`${LOG_PREFIX}:dev`); const error = debug(`${LOG_PREFIX}:error`); export { info, dev, error, }; And I currently log other stuff like: import { info } from './debug'; info('App

No Request Status in Node.js Morgan Logging

╄→尐↘猪︶ㄣ 提交于 2019-12-24 00:58:12
问题 I'm running a node.js app on an Azure VM (with PM2 handling load balancing and restarting). Here's the server set up and logging code: var logger = require('morgan'); var app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(flash()); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', routes);

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

一世执手 提交于 2019-12-10 13:28:01
问题 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 '{ write: (message: string, encoding: any) => {}; logger: any; }' is not assignable to type '(options?: any) => ReadableStream'. Object literal may only specify known properties, and 'write' does not exist in type '(options?: any) => ReadableStream'. Here

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

夙愿已清 提交于 2019-12-10 12:27:57
问题 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 (winston.Logger)({ ^ TypeError: winston.Logger is not a constructor Please guide me, Why this error and what should I have to do for solving this issue. "morgan": "^1.9.0", "winston": "^3.0.0" Following is my code in logger.js file. var appRoot = require(

Nodejs - How to use morgan with debug

岁酱吖の 提交于 2019-12-04 13:09:36
Morgan outputs requests directly to the console. How can I redirect them to npm debug so that it follows the same format as the other stuff which is being logged? My debug.js config looks like the following: import debug from 'debug'; const LOG_PREFIX = 'api'; const info = debug(`${LOG_PREFIX}:info`); const dev = debug(`${LOG_PREFIX}:dev`); const error = debug(`${LOG_PREFIX}:error`); export { info, dev, error, }; And I currently log other stuff like: import { info } from './debug'; info('App is up and running!'); My current morgan call is: app.use(morgan('combined')); Morgan accepts an

stream.write is not a function when using morgan with logger

a 夏天 提交于 2019-12-02 06:17:54
问题 Basically i am trying to implement logger for the nodejs , using morgan and winston. When i am trying to use morgan , throwing an error of stream.write is not a function. Since i want get the file name , i am passing the module, from module object there is a property called filename. Below is my code. // Winston.js const appRoot = require('app-root-path'); const { createLogger, format, transports } = require('winston'); const { combine, timestamp, label, printf } = format; const path =

stream.write is not a function when using morgan with logger

荒凉一梦 提交于 2019-12-02 03:53:47
Basically i am trying to implement logger for the nodejs , using morgan and winston. When i am trying to use morgan , throwing an error of stream.write is not a function. Since i want get the file name , i am passing the module, from module object there is a property called filename. Below is my code. // Winston.js const appRoot = require('app-root-path'); const { createLogger, format, transports } = require('winston'); const { combine, timestamp, label, printf } = format; const path = require('path'); // Custom Format const customFormat = printf(info => { return `${new Date(info.timestamp)} |

Winston / Morgan logging avoiding duplicate entries

主宰稳场 提交于 2019-11-28 09:58:37
问题 I just implemented Winston Logging and it works as expected but i came accross a few issues which i cant find answer for. The way winston works as far as i can tell, the set log level and anything below as far as priority gets used, like on error it will also include info logs etc. Is there a way to create a specific log level lets call it HTTP or db where i only log http or db events to and they don't end up in the combined file or console ? 回答1: A better solution is to use a single logger