【问题标题】:Cannot see loggly-winston debug log in UI在 UI 中看不到 loggly-winston 调试日志
【发布时间】:2021-10-15 04:36:38
【问题描述】:

当我拨打winston.debug 时,我看不到任何日志。我认为是因为我需要更改允许看到的日志级别? Link to winston documentationLoggly node.js documentation.

安装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
    }
}

【问题讨论】:

    标签: node.js typescript winston loggly


    【解决方案1】:

    我联系了 loggly 的支持,他们告诉我设置 winston 的 level

    private logOptions: LogglyOptions = {
        token: "my-customer-token",
        level: config.production ? "error" : "debug",
        subdomain: "myDomain.com",
        tags: ["Winston-NodeJS"],
        json: true,
    };
    

    为了方便起见,我创建了一个enum

    export enum WinstonLogLevelsEnum {
        ERROR = "error",
        WARN = "warn",
        INFO = "info",
        HTTP = "http",
        VERBOSE = "verbose",
        DEBUG = "debug",
        SILLY = "silly",
    };
    

    【讨论】:

      猜你喜欢
      • 2017-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多