https://github.com/joyent/node/wiki/modules#wiki-logs 好多日志模块,都看花了眼,大家都用哪个记录日志呢?
Logging and dumping
ain — Brain-free syslog logging Caterpillar — Caterpillar is an awesome, simple, intuitive console logger for node.js. It supports grouping of messages, filtering log levels, colors, times, modules, custom formatters and custom transports. cfdump.js — a more visually inspiring way to dump your objects to a browser flume-rpc — A flume-compatible (RPC) logging source and sink gelf-node - gelf-node is a full implementation for sending messages in GELF (Graylog Extended Log Format) from node.js to Graylog hexy.js — hex pretty printing like xxd inspect — hierarchical object inspection displaying ancestry, properties, methods, and accessors in great detail. jog — JSON-based logger with multiple stores, namespacing, CLI and more log.js — light-weight logger that works with any writable stream, also supports a streaming parser for reading the log files generated log4js-node — a port of log4js framework for node.js logging — Super sexy color console logging. logly — A minimal logging utility to support verbose and debug modes with basic colors logule — A sexy portable logging utility using colors nlogger — Logging lib that can print also module names and line numbers, optionally in color node-logentries — A winston-compatible wrapper library for the logentries.com service node-logging — Simple colorized logging for Node.js with request logger Express middleware node-streamlogger — Extensively customizable logging, with support for rotation node-tick — v8.log processor NodeLog — Logging library for Node.js based on the java.util.logging library. nogg — Simple file/stdio logging for node.js spruce — configurable node.js logging module tracer — A powerful and customizable logging library for node.js. support color console with timestamp, line number, method name, file name and call stack. you can set transport to file, stream, database(ex: mongodb and clouddb, simpledb). keywords: log, logger, trace underscore.logger — Cross-browser and Node.js empowered logging that can be used as an Underscore mixin. Windows Event Log Js — native Node.js module to log messages to the Microsoft Windows EventLog Winston — A multi-transport async logging library for node.js PuperGrep - Real-time web view for your logs with hightlighting, grep and more.
这种问题不用再问了,呵呵。在网站上方的搜索框里面输入“log”一搜,好多前辈有答案啦。
我比较了下tracer和bunyan,bunyan虽然理念不错,但是考虑到易用性和一些特性功能在实际生产上会用到的频率,决定在项目里面先使用tracer,功能还是挺强大的。
http://cnodejs.org/topic/4f50628498766f5a61082c93 https://github.com/baryon/tracer https://github.com/trentm/node-bunyan
把这么老的帖子翻出来会不会惹人烦呢?
作为Node的新人,看到的Node模块中没有一个公共的log库,而且大多数module都是采用console进行错误输出,奇怪生产系统中如果没有文件日志会是怎样?在模块列表中看到了nodejs-log4js(貌似应用不多),看到了Winston(简单实用,Nodejitsu用了这个模块),然后就翻到了这个帖子,将log的目标锁定在tracer和bunyan。
tracer:输出到文件、定义输出格式(format)、滚动日志文件、日志级别 bunyan:除了普通的日志功能外,几个特点:JSON格式、Child(跟踪日志调用栈)、DTrace(动态调整日志级别)。Joyent在产品实践系列debug部分提到这个模块,当时没有仔细看,重新翻出来看看,果然强悍!
个人开发tacer足够了,生产环境(尤其是分布式系统)中bunyan的特性更加吸引人。