[英]Nodejs logging module - production env
I am currently working on NodeJS application project.我目前正在研究 NodeJS 应用程序项目。
This application basically performs:这个应用程序基本上执行:
Interaction with Database (1000 request/response processing per min)与数据库的交互(每分钟 1000 次请求/响应处理)
Server side processing logic using information obtained from database使用从数据库获取的信息的服务器端处理逻辑
Client request handling (100 request for every 5 mins)客户端请求处理(每 5 分钟 100 个请求)
For any project, logging information is key to identify any failures/processing state.对于任何项目,日志信息是识别任何故障/处理状态的关键。
I tried winston nodejs log framework, but it happened that it does not support the following information:我试过winston nodejs日志框架,但碰巧不支持以下信息:
File Name文档名称
Function Name函数名称
Line No行号
Process ID进程标识
Host name etc主机名等
Hence I decided to go for bunyan logging framework.因此我决定使用bunyan日志框架。 I understand Bunyan framework supports these things.
我了解 Bunyan 框架支持这些东西。
Please share your thoughts whether this can be used for production code.请分享您的想法,这是否可以用于生产代码。
If not possible, I fear how other nodejs projects used in many web application gets these information.如果不可能,我担心许多 Web 应用程序中使用的其他 nodejs 项目如何获取这些信息。
I could not get any production ready log framework in nodejs which supports these functionalities.我无法在支持这些功能的 nodejs 中获得任何生产就绪的日志框架。 I googled for information and search results leads to winston/bunyan.
我在谷歌上搜索信息,搜索结果指向 winston/bunyan。
If your question still actual, you can try this one如果你的问题仍然存在,你可以试试这个
Usage example使用示例
const logger = require('@grdon/logger')({
defaultLogDirectory : __dirname + "/logs",
})
// ...
logger([process.argv], 'logfile.txt')
Result will be结果将是
Start:Wed Sep 22 2021 13:52:22 GMT+0400
[
[
'C:\\Program Files\\nodejs\\node.exe',
'D:\\todel3\\test.js',
[length]: 2
],
[length]: 1
]
Trace:Object- File D:\grdon-test\test.js:6
Finish
filename, line, function names supported, and many other options支持的文件名、行、函数名和许多其他选项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.