Tag: winston

Node.js @ google-cloud / logging-winston不能在GCE实例内工作

我正在使用npm @ google-cloud / logging-winston将应用程序日志事件发送到Google堆栈驱动程序日志接收器。 下面是我的代码片段,它在我的本地macbook中工作得很好。 当我尝试在GCE实例(谷歌云上的Ubuntu 16.10图像计算实例)中运行它时,它不会将日志事件发送到日志接收器,我无法在Google云日志logging仪表板上看到它。 任何帮助在这里赞赏 ///// code start here const winston = require('winston'); const Logger = winston.Logger; const Console = winston.transports.Console; const LoggingWinston = require('@google-cloud/logging-winston'); // Instantiates a Winston Stackdriver Logging client const loggingWinston = LoggingWinston({ projectId: 'myproject-id', keyFilename: 'mykey.json', level: 'info',// log at 'warn' and above , labels: { "env": […]

如何让温斯顿每日文件旋转login到相应的级别文件

我已经为我的应用程序定义了自定义级别,如下所示。 protected levels: Level = { "error": 0, "warn": 1, "info": 2, "debug": 3, "trace": 4 }; 我正在使用每日文件旋转运输来获得每日login在单独的文件。 const options: Object = { name: this.level, filename: logFilePath, dirname: WinstonLogAgent.DIR_LOG, datePattern: "yyyyMMdd.", prepend: true, level: this.level, levels: this.levels, maxsize: this.maxFileSize, maxFiles: this.maxFileCount, handleExceptions: true, humanReadableUnhandledException: true }; this.transportInstance.push(new (winston.transports.DailyRotateFile)(options)); 如果我将日志级别定义为'info',它将创build一个名为info.log的日志文件,并将logging级别'info','warn'和'error'(跟踪和debugging将被忽略)。 但是我想要的行为是不同的。 如果我指定的级别是'信息',我logging级别'信息','警告'和'错误',那么应该为每种types的日志创build单独的文件。 即'信息'级别应logging到info.log和'警告'级别logging到warn.log。 我已经尝试指定五个不同的日常文件旋转运输,每个具有独特的水平。 那么我发现的问题是有重复的日志条目。 例如,如果logging“错误”级别,则当日志logging级别设置为info时,它将logging到info.log,warn.log和error.log。 […]

如何输出process.stderr.write到winston

使用winstonlogging器将内容写入文件,但只有在使用customlogger.error时才起作用。 如果节点正在输出一些像下面的参考错误 ReferenceError: aksbd is not defined at /home/nigilan/Desktop/homepagelogger/app.js:53:20 at Layer.handle [as handle_request] (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/layer.js:95:5) at next (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/layer.js:95:5) at /home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/index.js:335:12) at next (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/index.js:275:10) at /home/nigilan/Desktop/homepagelogger/app.js:38:5 at Layer.handle [as handle_request] (/home/nigilan/Desktop/homepagelogger/node_modules/express/lib/router/layer.js:95:5) 如何使用Winston来存储上面的错误? PSlogging未处理的exception是nodejs服务器工作正常。

如何与node.js中的winston同步logging

我相当新的node.js,我来自C#/ Java的土地,所以我需要一些日志logging的帮助。 现在我正在用Selenium编写testing,使用本地捆绑和mocha作为我的testing框架。 我有一个base-page.js – 所有其他Page Objects基类,其中包含与页面交互的基本方法和logInfo(message)方法。 就目前而言,我已经决定和winston一起去伐木了。 我的logging器configuration如下所示: import winston from 'winston'; const tsFormat = () => (new Date()).toLocaleDateString() + ": " + (new Date()).toLocaleTimeString(); const logger = new (winston.Logger)({ transports: [ new (winston.transports.Console) ({ timestamp: tsFormat, colorize: true }), new (winston.transports.File) ({ filename: 'logs.log'}) ] }); logger.level = 'silly'; logger.cli(); 它工作得很好。 事情是,当我运行我的testing用例时,所有的日志消息都会立即logging下来,而不是作为他们应该logging的函数的一部分,至less从C#/ Java的angular度来看。 […]

当nsp在一个依赖关系的依赖中find一个漏洞时该怎么办

我在我即将部署的项目上运行了nsp,并且发现了这个漏洞 Name │ mime CVSS │ 7.5 (High) Installed │ 1.2.11 Vulnerable │ < 1.4.1 || > 2.0.0 < 2.0.3 Patched │ >= 1.4.1 < 2.0.0 || >= 2.0.3 Path │ myProject@1.0.0 > winston-s3@1.0.0 > winston@0.7.3 > request@2.16.6 > form-data@0.0.10 > mime@1.2.11 More Info │ https://nodesecurity.io/advisories/535 现在我明白,我需要更新“MIME”依赖,但我的问题是,该漏洞是一个依赖依赖的依赖内。 我的'winston-s3'依赖是最新的,当我要去'node_modules / winston-s3 / node_modules / winston /'时,没有'node_modules'目录和“mime” […]

温斯顿logging器exitOnError:false仍然退出

我有一个非常基本的winston设置: src/appSetup.js const logger = new winston.Logger({ transports: [ new winston.transports.Console({ timestamp: true, }), ], exitOnError: false, }); module.exports.logger = logger; 我使用这样的东西: const logger = require('../src/appSetup').logger; const concatenater = (string1) => { if (condition-check) { // do something } logger.error('error message'); return ''; // this is necessary as tests expects empty string on if-condition fail […]

winston postgresql自定义sql / tableName不工作

const logger = new (winston.Logger)({ transports : [ new winston.transports.PostgreSQL({ connString : 'xxxxxxxxxxx', schema : 'public', //tableName : 'logEntry', customSql:'INSERT INTO public."logEntry"(logLevel, msg, meta) VALUES ($1, $2, $3);', }) ]; }); 数据没有插入到表中,并在控制台中收到警告: 未处理的承诺拒绝已被弃用。 将来,未处理的承诺拒绝将使用非零退出代码来终止Node.js进程。 任何人都可以告诉我这个代码有什么问题吗?

logging温斯顿 – 蒙戈德,特快 – 温斯顿和温斯顿

我使用winston,expressWinston,winston-mongoDB来pipe理我的NodeJs应用程序中的日志。 用express-winston使用winston-mongodb传输; 我可以将日志以下面的格式存储到我的mongoDB集合中。 (元:真) { "_id" : ObjectId("5a124f9781d911337ebeb98d"), "timestamp" : ISODate("2017-11-20T03:44:23.336Z"), "level" : "info", "message" : "GET /stylesheets/bootstrap.css 304 2ms", "meta" : { "res" : { "statusCode" : 304 }, "req" : { "url" : "/stylesheets/bootstrap.css", "headers" : { "host" : "localhost:3000", "connection" : "keep-alive", }, "method" : "GET", "httpVersion" : "1.1", "originalUrl" : "/stylesheets/bootstrap.css", […]

winston只有在debugging时才将日志保存到文件中

我在快递应用程序中使用winston。 当我使用node app.js winston运行应用程序时,只logging到控制台,但是如果我使用VSCodedebugging器运行应用程序,它也应该logging到error.log文件。 我正在使用winston v2.3.1,无法升级。 我的代码: const logger = new winston.Logger({ transports : [ new winston.transports.Console(), new winston.transports.File({ filename : './app/error.log', handleExceptions: true, humanReadableUnhandledException: true }) ], handleExceptions : true }); 会是什么呢?

如何从单独的脚本中旋转Winston日志?

我们使用node.js和winston来删除日志文件。 我们有一个用PHP编写的自定义日志轮转脚本,我们希望在这些日志文件上使用它。 但脚本只是移动在这种情况下不起作用的文件,因为winston在该文件上有一个打开的stream。 我怎样才能移动一个Winston的日志文件,所以Winston知道创build一个新的日志文件,一旦我移动它?