Tag: bunyan

单独的信息和错误日志bunyan

正如我在博客中看到许多日志,我发现bunyan适合于日志logging,但它有问题,它不能根据他们的级别login文件。 下面是我正在关注的代码结构 const RotatingFileStream = require('bunyan-rotating-file-stream'); const bunyan = require('bunyan'); var log = bunyan.createLogger({ name: 'ShotPitch', streams: [{ name: 'info', level: 'info', stream: new RotatingFileStream({ path: 'info.%d-%b-%y.log', period: '1d', // daily rotation totalFiles: 10, // keep 10 back copies rotateExisting: true, // Give ourselves a clean file when we start up, based on period threshold: […]

自定义logging器和Socket.io 1.x

在Socket.io的 1.0之前的版本中,似乎可以在实例化时使用logging器选项来设置logging器 ,但是我似乎无法在1.0之后做到这一点。 我是正确的,他们已经删除了这个选项,有没有什么好的方法,我可以通过钩住/侦听错误从Socket.io似乎现在使用debugging模块,而无需修改现有的模块。 我想用Bunyan来logging我的socket信息。

Bunny logger.info错误在Restful API

我正在开发一个Restful API,我正在用bunyanlogging所有重要的步骤,包括请求。 我遇到了两个与日志logging有关的问题:我的第一个问题是,当我login它们时,所有的对象,而不是像独立对象一样出现在msg字段中,就像string一样。 这里是我的代码来logging请求: var logger = bunyan.createLogger({ name: 'main', streams: [{ level: 'info', path: './logs/requests.log' }] }); logRequest = function(request){ logger.info("Request started.", {id: request.id}, {method: request.method}); }; 当我看到request.log文件时,它就像这样( 我刚刚添加了一些标签,使它更舒适 ): { "name": "logger", "hostname": "LLAS", "pid": 7700, "level": 30, "msg":"Request started. { id: '1428527975041:LLAS:7700:i898o4l5:10000'{ method:'post' } ", "time":"2015-04-08T21:19:35.055Z", "v":0 } 所以我的问题是, “味精”领域,我想看到“ID”和“方法”像其他领域而不是一个string。 IE : […]

debugging打破与bunyan.createLogger – 节点v5.8发射

当我尝试使用bunyan启动node.js应用程序时,debugging器会停止,一旦我尝试创buildlogging器。 当我遍历代码时,我可以深入到createLogger并find它的中断点。 在node_modules / bunyan / lib中,debugging器在579行分离 – assert.ok(isWritable(s.stream), '"stream" stream is not writable: ' + util.inspect(s.stream)); debugging器工作,直到我设置logging器,之后,它分离,我永远不会步进到logger.info行。 import bunyan from 'bunyan'; const logger = bunyan.createLogger({ name: 'test' }); //debugger detaches logger.info('Hello logger'); // debugger will NOT step to this line winston不会发生这种情况。 我认为这与winston使用控制台和bunyan使用stream有关。 import winston from 'winston'; winston.info('Simple log'); const bp = 'The debugger will […]

如何根据date筛选bunyan日志?

有一个bunyan日志,这里是一个样本入口 [2016-05-31T15:38:47.889Z] FATAL: jklajsd-utilities/23399 on aaa.bbb.ccc.com: 0: { "code": "EADDRINUSE", "errno": "EADDRINUSE", "syscall": "listen", "address": "0.0.0.0", "port": 5566 } 好的,我想在那之后find所有的条目: bunyan /opt/aaa/.pm2/logs/cccc-out-15.log -c 'this.date >= new Date("2016-05-31T15:38:47.889Z")' 没有结果。 也试过this.time 。 bunyan文档说, time是正确的领域,但它不工作。 new Date("2016-05-31T15:38:47.889Z")'有效: > new Date("2016-05-31T15:58:50.475Z") Tue May 31 2016 08:58:50 GMT-0700 (PDT) 日志过滤当然是有效的: $ bunyan /opt/aaa/.pm2/logs/cccc-out-15.log -c 'this.level === DEBUG ' |wc -l […]

如何将bunyan日志loggingfunction绑定到ES6中的类function?

今天有一点烦恼,仍然有一个错误。 文档在这里。 最近的我是这样的: constructor(region, sslEnabled = true, logger = () => {}, errorLogger = () => {}) { if (region === undefined || !region) throw new Error("Initialization error: region is required"); this.log = () => {}; // these two lines might be unnecessary this.logError = () => {}; // this.log = logger.bind(this); this.logError = errorLogger.bind(this); […]

在bunyan日志logging中格式化输出

我正在试验节点bunyan模块。 作为其中的一部分,我想知道关于bunyan的一些事实.. bunyan是否有助于改变在bunyan日志上印刷内容的顺序。 例如默认情况下,时间戳会打印在最后…有没有办法在开始时打印? 如果是,请与我分享.. Bunyan日志将通过指定应用程序中的pathlogging到文件中。 而不是在应用程序中指定,我们可以指定属性文件中的其他地方。如果是这样,请分享如何做到这一点…

使用node.js Bunyan与Intellij进行日志logging

我使用bunyan日志logging一个node.js子系统,通常使用intellij IDEA。 我想使用bunyan漂亮的打印机,以便我可以从intellij中获得buynan / json日志的好处。 我找不到任何办法做到这一点,但觉得这一定是可能的。 有没有人想出如何做到这一点? 更新: 下面@ cyue的答案就像一个冠军。 当我没有马上find东西的时候,我最终在一个日志logging类中创build了这样的东西,我用它来包装这个function,并将它用于testing服务器: var bunyan = require('bunyan'); var bunyanFormat = require('bunyan-format'); var standardOut = bunyanFormat({outputMode: 'long', levelInString: true}); var errorOut = bunyanFormat({outputMode: 'bunyan', levelInString: true}); var bunyanLogger = bunyan.createLogger({ name: 'tot', streams: [ { stream: process.stdout , level: 'trace' }, { stream: process.stderr , level: 'warn' } […]

是否有可能重写bunyan的日志function?

我使用bunyan.js作为我的日志logging解决scheme,我想为它的日志function添加function。 例如,我想每次有一个调用log.fatal()时发送一些东西给第三方API 那可能吗? 我查看了文档,没有看到任何可以注册的事件或其他解决scheme。 谢谢!

在bunyan多个日志path

我使用Bunyan与Restify创build一个access.log,它将存储有关端点,状态码等请求的信息…但是,我想从这个文件中分离错误并将它们存储在一个单独的日志文件。 我已经尝试通过向Bunyanlogging器实例添加额外的stream来创build第二个错误logging器,但是错误不会写入错误日志文件。 任何想法,为什么? var log = new Logger({ name: 'logga', streams: [ { stream: process.stdout, level: 'debug' }, { path: './logs/access.log', level: 'trace' }, { path: './logs/error.log', level: 'error' } ], serializers: Logger.stdSerializers }); server.on('uncaughtException', function (request, response, route, error) { log.error(error); });