A Javascript Frontend Logging System That Logs To Our Backend?
Solution 1:
First, I wrote and maintain log4javascript, so I'm declaring my interest up front. I also use it every day in my work, so I have some experience of it as a user. Here's how I would deal with your questions, specifically relating to log4javascript:
Use log4javascript's
AjaxAppenderfor server logging;debug,info,warninganderrorare all supported, as well astraceandfatal;Use a
BrowserConsoleAppenderto log to FireBug or the native browser console;If you don't want to remove all debug logging calls from you production code, you can either adjust your logger's threshold (using
log.setLevel(log4javascript.Level.ERROR), for example, which will suppress all log calls with priority less thanERROR). If you want to suppress all logging calls, you can drop in a stub version of log4javascript in your production code.You'll need to write a bit of code to do this using
window.onerror. Something likewindow.onerror = function(msg, file, line) { log.error("Error in " + file + " on line " + line + ": " + msg); }I'm not sure how you want to tie in with Google Analytics. log4javascript has no particular support for it.
Solution 2:
The idea sounds good here. Just be aware of what exactly it is you are looking to log client-side and have at it.
I would recommend using log4javascript for logging. The log4 api is pretty straight foward.
Solution 3:
Here is another question from here on SO about this very issue.
Some recommendations are: log4js, log4javascript, and Blackbird.
FWIW, log4js was the accepted answer there. I don't have experience with any of these platforms, so I can't really recommend one over the other.
Post a Comment for "A Javascript Frontend Logging System That Logs To Our Backend?"