configure log4javascript to struts web application
How can we write the JavaScript info and error messages to the log file using log4j.
Please find the code below
<script type="text/javascript" src="././scripts/log4javascript.js"></script>
<script type="text/javascript">
var log = log4javascript.getDefaultLogger();
log.removeAllAppenders();
log.addAppender("start logging");
</script>
function writetoLog()
{
log.info("Start the Script Log..");
}
<body onload="writetoLog();">Some html code here </body>
This info messages is not write 开发者_高级运维to the my log file.
Please suggest
You need to create an AjaxAppender
. It's covered in the documentation of log4javascript (for example, in the quick start tutorial: http://log4javascript.org/docs/quickstart.html).
var log = log4javascript.getLogger("server");
var ajaxAppender = new log4javascript.AjaxAppender("/yourapp/jslog.do");
log.addAppender(ajaxAppender);
log.debug("Testing server log");
精彩评论