jquery - A JavaScript frontend logging system that logs to our backend? -
we have established logging system our server-side services. specifically, our django project makes heavy use of python logging module, call calls logger.info()
, logger.warn()
, logger.error()
picked our centralized logging system.
i equivalent on our frontend, , i've got few ideas:
there sort of custom logging object exposed via javascript send messages backend via xmlhttprequest.
i'd have equivalent logging levels on client-side:
debug
,info
,warning
,error
.when we're developing locally (debug mode), i'd logging messages logged browser/firebug console via
console.log()
.in production,
debug
messages should dropped completely.i recall seeing way capture uncaught javascript exceptions, these should logged @
error
level.we're using google analytics event tracking, , it'd nice whatever system create tie somehow.
is idea? how this? there existing solutions?
(fwiw, we're using jquery on frontend.)
update: simplified question here: https://stackoverflow.com/questions/1423267/are-there-any-logging-frameworks-for-javascript
first, wrote , maintain log4javascript, i'm declaring interest front. use every day in work, have experience of user. here's how deal questions, relating log4javascript:
use log4javascript's
ajaxappender
server logging;debug
,info
,warning
,error
supported,trace
,fatal
;use
browserconsoleappender
log firebug or native browser console;if don't want remove debug logging calls production code, can either adjust logger's threshold (using
log.setlevel(log4javascript.level.error)
, example, suppress log calls priority lesserror
). if want suppress logging calls, can drop in stub version of log4javascript in production code.you'll need write bit of code using
window.onerror
.window.onerror = function(msg, file, line) { log.error("error in " + file + " on line " + line + ": " + msg); }
i'm not sure how want tie in google analytics. log4javascript has no particular support it.
Comments
Post a Comment