登录express js到输出文件? [英] Logging in express js to a output file?

查看:75
本文介绍了登录express js到输出文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

记录我的快捷js webserver的最佳方法是什么?内置的express.logger()只是在屏幕上显示日志。我也可以将它们记录到/ log文件夹中的文件中?此外,当前的记录器还会自动记录请求和响应。我需要将一些应用程序数据记录到日志文件中。这可以使用express.logger吗?



Regards,
Lalith

解决方案

查看表示扩展的连接中间件。 express.logger()与connect.logger()相同:



http://expressjs.com/api.html#middleware



http://www.senchalabs.org/connect/logger.html



记录器有一个流选项,可以设置要输出的位置。默认情况下,它发送到stdout。您也可以指定要使用的日志格式。


What is best way to log my express js webserver? The inbuilt express.logger() just displays logs on screen. Can I also log them into a file in /log folder? Also the current logger automatically logs the request and responses. I need to log some application data into the log files. Can this be done using express.logger?

Regards, Lalith

解决方案

Look at the connect middleware that express extends. The express.logger() is the same as the connect.logger():

http://expressjs.com/api.html#middleware

http://www.senchalabs.org/connect/logger.html

The logger has a stream option that can be set where you want the output to go. By default it sends it to stdout. Also you can specify the log format you want to use.

这篇关于登录express js到输出文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆