I cannot see any logs when I call winston.debug
. I think it is because I need to change the log level allowed to be seen? Link to winston documentation. Loggly node.js documentation.
Installation npm i winston-loggly-bulk @types/winston-loggly-bulk winston
import { Loggly, LogglyOptions } from "winston-loggly-bulk";
import winston from 'winston';
export class Server {
private logOptions: LogglyOptions = {
token: "my-customer-token",
subdomain: "myDomain.com",
tags: ["Winston-NodeJS"],
json: true,
};
private logger: winston.Logger;
private test: Test;
constructor() {
this.logger = winston.add(new Loggly(this.logOptions));
this.test = new Test(this.logger);
this.logger.info("mark1"); // I can see this in the loggly UI
this.logger.debug("mark2"); // I cannot see this log in the loggly UI
}
}
I contacted loggly's support and they told me to set winston's level
private logOptions: LogglyOptions = {
token: "my-customer-token",
level: config.production ? "error" : "debug",
subdomain: "myDomain.com",
tags: ["Winston-NodeJS"],
json: true,
};
I created an enum
to use for convenience:
export enum WinstonLogLevelsEnum {
ERROR = "error",
WARN = "warn",
INFO = "info",
HTTP = "http",
VERBOSE = "verbose",
DEBUG = "debug",
SILLY = "silly",
};