如何阻止 Loggly 打印到 stdout(或 stderr)并将日志发送到云端?

How can I stop Loggly from printing to stdout (or stderr) and just sending the logs to the cloud?

我们正在使用 Loggly 进行日志记录并且通常对它非常满意,但是在升级到 Winston 方法之后,我现在发现我的所有日​​志记录不仅会转到 Loggly 服务器,还会被 console.log输出到 stdout(或 stderr,以哪个为准)。

没有 whole lot to the documentation,而且我找不到关闭它的方法。这个练习的全部*点是我不想将所有这些日志保存在我的本地机器上,如果他们前往控制台,它们将在本地机器上结束。

我尝试从 winston.transports 对象中删除 Console 对象,但没有任何效果。

我有点没主意了。

如果删除默认控制台传输不起作用,您始终可以创建自己的记录器实例并使用它。

var winston  = require('winston');
require('winston-loggly');

var logger = new (winston.Logger)({
  transports: [
    new (winston.transports.Loggly)({
      inputToken: "TOKEN",
      subdomain: "SUBDOMAIN",
      tags: ["Winston-NodeJS"],
      json:true
    })
  ]
});

module.exports = logger;

您可以在 winston 文档中找到更多信息。 Using the Default Logger shows you the way to remove default console transport. The Instantiating your own logger 部分包含有关创建自定义记录器的信息。