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
If you have colorize turned on for the winston logger you will not get log level set correctly
The reason is that the first character is an escape character to make error display in red. https://github.com/namshi/winston-graylog2/blob/master/lib/winston-graylog2.js#L25
Not sure why you write that formatters can't be set on transport level see below how I did it and now it works!
Here is a sample what will work.
"use strict"; const os = require("os"); const winston = require("winston"); const { format } = winston; const WinstonGraylog2 = require("winston-graylog2"); const { NODE_ENV, GRAYLOG_URL, GRAYLOG_PORT, GRAYLOG_FACILITY_NAME, LOG_LEVEL, } = require("../config/env"); var grayLogOptions = { name: "Graylog", silent: false, level: LOG_LEVEL, handleExceptions: false, //showLevel: false, graylog: { servers: [ { host: GRAYLOG_URL, port: GRAYLOG_PORT, }, ], hostname: os.hostname(), facility: GRAYLOG_FACILITY_NAME, bufferSize: 1400, }, }; const winstonTransports = []; if (NODE_ENV === "production") { winstonTransports.push(new WinstonGraylog2(grayLogOptions)); } const logger = new winston.createLogger({ transports: winstonTransports, format: format.combine( format.errors({ stack: true }), // Handle errors (was automagic in winston@2) // new format.metadata(), ), }); logger.add( new winston.transports.Console({ format: winston.format.combine( format.splat(), // Handle splat (was automagic in winston@2) format.timestamp(), // { timestamp: true } format.colorize(), // { colorize: true }) format.simple(), // Default serialization in winston@2 ), }), ); module.exports = { logger };
The text was updated successfully, but these errors were encountered:
I think it was just assumed that you couldn't set the format at the transport level because the Winston formatting docs don't mention or show it.
Sorry, something went wrong.
No branches or pull requests
If you have colorize turned on for the winston logger you will not get log level set correctly
The reason is that the first character is an escape character to make error display in red.
https://github.com/namshi/winston-graylog2/blob/master/lib/winston-graylog2.js#L25
Not sure why you write that formatters can't be set on transport level see below how I did it and now it works!
Here is a sample what will work.
The text was updated successfully, but these errors were encountered: