Tag: winston

winston查杀节点进程

我添加了winstonlogging器到我的node.js代码,这个代码曾经运行直到被杀死。 在添加logging器之后,该过程就会死亡。 即使我只是要求logging器,而不是使用它。 我的logger.js是: var winston = require ('winston'), path = require ('path'); var DailyRotateFile = require('winston-daily-rotate-file'); var logger = new (winston.Logger)({ transports: [ new DailyRotateFile({ name: 'dropped-key', datePattern: '.yyyy-MM-ddTHH', filename: path.join(__dirname, "droppedKeyLog", "log_file.log"), level: 'silly' }), new DailyRotateFile({ name: 'errorLogger', datePattern: '.yyyy-MM-ddTHH', filename: path.join(__dirname, "errorLog", "log_file.log"), level: 'error' }), new DailyRotateFile({ name: 'debug-file', datePattern: […]

温斯顿 – 如何logging导致节点进程崩溃的错误?

我有一个快速的应用程序,有一些情况下,整个节点进程将失败,主要是ReferenceError。 我想知道是否有一种方法来设置Winston来处理节点崩溃,并logging显示在我的控制台中的问题。 例如,我可以强制我的应用程序崩溃,通过放入一个对window的引用,导致: ReferenceError: window is not defined 我怎样才能让winstonlogin呢? 在我的app.js中,我为Winston设置了以下设置,但不起作用: const winston = require('winston'); const logger = new (winston.Logger)({ transports: [ new (winston.transports.File)({ filename: `results.log`, timestamp: true, level: 'info', json: true, eol: 'n', handleExceptions: true, humanReadableUnhandledException: true }) ], exitOnError: false }); process.on('uncaughtException', function (error) { console.log('error'); // doesn't log this, }); 有人可以帮我吗? 基本上,我正在尝试logging我的控制台中出现的这个错误,如果我故意让应用程序崩溃: Listening […]

nodejs winston – 使用多个参数logging

我试图用winston进行日志logging,但是我看到,如果我想用2个参数获取数据,那么我得到的日志,但如果我想获得3个参数,那么我没有得到的数据, 例如: logger = new (winston.Logger)({ transports: [ new (winston.transports.Console)({colorize : true, timestamp:true}), ] }); 现在试图获取日志如下: 1. logger.info("We got the data %s, %d", data, port); O/P: We got the data %s, %d => No data and port value 2. logger.info("We got the data, port", data, port); O/P: We got the data, port => No data […]

如何使用Winston / MorganloggingJSON HTTP响应

我使用Winston和Morgan来处理Sails.js中的所有后端日志logging,我需要能够logging来自HTTP请求的响应。 我需要将它们logging在一个文件中。 我的logFile目前需要显示所有的http请求,但是它不显示响应。 我已经search了摩根和温斯顿的所有选项,并找不到一个方法/选项来做到这一点。 我只是想知道你们是否有任何build议如何做到这一点? 谢谢!

Node.js – Elastic Beanstalk – Winston – / var / log / nodejs

我们一直在弹性豆杆上使用温斯顿一段时间,它运作良好。 但是我们总是编写两组日志 – 一个是系统节点日志,在/ var / log / nodejs中,然后我们有自己的应用程序特定文件,它们位于应用程序根目录的日志目录中。 我们决定尝试整合我们的日志,这使得他们在豆杆控制台中很方便。 但是,/var/log/nodejs/nodejs.log,当一个新实例启动时,日志的权限限制为root,并且应用程序崩溃。 nodejs进程不能写入它们。 我们可以将文件传给nodejs,但这不是一个好的长期解决scheme。 有没有人得到这个设置? 如果是的话,你是怎么做到的?

使用邮件传输的Node.js winston日志logging只发送uncaughtException作为电子邮件

有没有办法将uncaughtException发送到使用Winston模块的Mail传输的电子邮件地址? 我不想使用任何其他方法来发送电子邮件uncaughtExceptions 。 我发誓,有这样的方式,但我更热衷Winston的邮件传输工作。 显然这个configuration不支持 handleException: true 如果可以的话,会很酷。 我使用其他传输来logging所有的exception,但是,当涉及到uncaughtExceptionexception我不仅要logging它,而且还会发送电子邮件,当我们可以ssh进入系统并解决问题。 显然我会forever或使用pm2作为主pipe,无论如何将重新启动应用程序。 似乎只能通过电子邮件发送例外,但没有人回应这个问题。 我做了+1这个问题,希望得到的东西。 有没有人使用Winston的邮件传输发送uncaughtException只。 如果是的话,你是如何解决这个问题的? 分享将不胜感激。

在HapiJS置信度configuration对象中设置过滤对象的默认值

我在我的项目中使用Confidence库(在HapiJS套件中)进行configurationpipe理(这个configuration文件专门用于WinstonJS传输),而且我想知道是否可以在一个filter中设置单个项目的默认值目的。 我不确定我是否解释了这个问题,我不确定正确的术语是什么,所以inheritance了一个例子: 我目前有一部分configuration设置: module.exports = { $filter: 'env', development: { level: { console: 'debug', file: 'debug' }, path: 'app-core.log' }, staging: { level: { console: 'warn', file: 'warn' }, path: 'app-core.log' }, production: { level: { console: 'error', file: 'error' }, path: 'prod-app-core.log' } } 但是因为所有环境项目的path都应该是相同的,除了production ,我希望能够为path值设置默认值。 像这样的东西: module.exports = { $filter: 'env', development: { […]

winston和loggly没有显示在loggly仪表板上

试图用winston设置loggly,没有任何显示! 我尝试了一个全面的来源组: 并尝试了一个简单的信息日志: winston = require 'winston' Loggly = require('winston-loggly').Loggly winston.add Loggly, { subdomain: "my-subdomain", inputToken: "my-input-token-ihawof9ahw3fo9ahwe", json: true } winston.info 'Hello Loggly!' 什么可能是错的?

通用error handling程序MEANJS,mongoose,温斯顿

所以我最近开始在节点和平均编程,而在与JAVA工作时,我总是专注于最好的模式来创build可靠的应用程序,即使学习曲线正在杀死我,我在这里也一样。 无论如何,我试图实现一个通用的error handling程序使用MEANjs在中央的地方有一个exception处理程序,logging错误到一个文件,并在发生这种情况时发送电子邮件。 以mongoose为例 app.route('/process/:pId').get(function(req, res){ pModel.findById(req.params.pId, function(err, doc){ if(err) {//this is so console.log(err);//repetitive so I would res.send(500, 'Error: error.'); }//like to send all these errors to a central handler like in express.js below res.json(200, {data: doc}); }); };); 这是express.js中的处理程序: app.use(function(err, req, res, next) { if (!err) return next(); // can I call another error […]

解释在winstonlogging器中使用的级别

嘿,我正在使用这个温斯顿logging器,请解释使用传输内的水平,如果我使用logging器与信息logging时会发生什么,我必须使用debugging,而我login我的数据。 var logger = new (winston.Logger)({ transports: [ new (winston.transports.Console)({ level: 'debug', json: true }), new (winston.transports.File)({ name: 'order_check', filename: './logs/order_check.log', level: 'debug' }) ] }); logger.log("info","request body");