最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

logging - JavaScript logger into a rolling file - Stack Overflow

programmeradmin2浏览0评论

i've a JavaScript application.

I'd like to use a logger but instead of logging to a console (like Firebug or Yahoo UI), I'd like to log to a file or several files.

Ideally, It should be possible to back up the files when they reach a certain limit.

thanks.

i've a JavaScript application.

I'd like to use a logger but instead of logging to a console (like Firebug or Yahoo UI), I'd like to log to a file or several files.

Ideally, It should be possible to back up the files when they reach a certain limit.

thanks.

Share Improve this question asked Sep 2, 2010 at 12:15 LB40LB40 12.3k17 gold badges75 silver badges109 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 4

Writing to a file on the client machine is not generally possible via JavaScript running in a web page. It can be done in IE using ActiveX (when the user has allowed it) and I think also in Firefox when the user has enabled an obscure setting, but is generally not possible. There are various questions about this in Stack Overflow. For example:

  • Is it possible to write to a file (on a disk) using JavaScript?
  • Read/write to file using jQuery

Bearing that in mind, it has never seemed worthwhile implementing a local file appender in log4javascript. If you do want to log to a file, I would suggest using the AjaxAppender to send log messages to the server and log those messages to log4j / log4net / log4php / whatever set up with a rolling file appender.

You may want to check out log4js. It is a logging API based on the popular log4j framework. It is an open source project, using the Apache License 2.0.

You may also want to check out the log4javascript project, written by the Stack Overflow regular @Tim Down.

发布评论

评论列表(0)

  1. 暂无评论