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 02 Answers
Reset to default 4Writing 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.