We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up the use of winston and express-winston logging and stream data into GCP Logging.
winston
express-winston
Set up looks like:
import winston from 'winston'; import ExpressWinston from 'express-winston'; import { LoggingWinston } from '@google-cloud/logging-winston'; import config from '../config'; const logFormat = winston.format.printf( (info) => `${info.timestamp} ${info.level}: ${info.message}`, ); const transports: winston.transport[] = [ // This transport dumps into console new winston.transports.Console({ format: winston.format.combine(winston.format.colorize(), logFormat), }), new LoggingWinston({ projectId: config.projectId, // its a config }); ]; const logger = winston.createLogger({ level: config.logs.level, // defaults to 'info' transports, format: winston.format.combine( winston.format.colorize(), winston.format.json(), winston.format.prettyPrint(), winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.metadata({ fillExcept: ['message', 'level', 'timestamp'], }), ), }); // Whitelisting request and response bodies to be logged ExpressWinston.requestWhitelist.push('body'); ExpressWinston.responseWhitelist.push('body'); const expressLogger = ExpressWinston.logger({ level: config.logs.level, // defaults to 'info' format: winston.format.combine( winston.format.colorize(), winston.format.json(), winston.format.prettyPrint(), winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), ), transports, // remove the following headers from getting logged headerBlacklist: ['authorization', 'cookie', 'set-cookie'], colorize: true, msg: '{{res.statusCode}} {{req.method}} {{req.url}} {{res.responseTime}}ms', ignoreRoute: (req) => ignoredRoutes.indexOf(req.originalUrl || req.url) >= 0, }); export { logger, expressLogger };
This logger is then used as follows:
import express from 'express'; import { logger, expressLogger } from './logger'; // . . . const app = express(); app.use(expressLogger); logger.info('server starting');
Importantly, all of this works great and like a charm at first!.
e.g.
But then after a few days, the express logger stops logging -- without any error in the logs. The winston logger continues to work fine.
This forces me to restart the server to make it work again. Any suggestions on how to resolve this?
Thanks
The text was updated successfully, but these errors were encountered:
What version of express-winston and what version of winston are you using? This defect was present in an older version.
Sorry, something went wrong.
Hi @yinzara!
express-winston 4.2.0 winston 3.8.1 @google-cloud/logging-winston 5.1.0 Node 16.17.1 NPM 8.15.0 running os: Debian GNU/Linux 10 (buster)
4.2.0
3.8.1
5.1.0
16.17.1
8.15.0
Debian GNU/Linux 10 (buster)
No branches or pull requests
Set up the use of
winston
andexpress-winston
logging and stream data into GCP Logging.Set up looks like:
This logger is then used as follows:
Importantly, all of this works great and like a charm at first!.
e.g.
But then after a few days, the express logger stops logging -- without any error in the logs. The winston logger continues to work fine.
This forces me to restart the server to make it work again. Any suggestions on how to resolve this?
Thanks
The text was updated successfully, but these errors were encountered: