1、定義log4js服務(wù)類,用于初始化log4javascript相關(guān)參數(shù)//啟用javascript日志功能varlogger=log4javascript.getLogger("main");log4javascript.setEnabled(true);varappender=newlog4javascript.InPageAppender();appender.layout.pattern='%d{yyyy-MM-ddHH:mm:ss,SSS}[%c]%-5p-%m{1}%n';logger.addAppender(appender);//點(diǎn)擊Ctrl鍵時顯示/隱藏日志控制臺document.onkeydown=function(evt){varVK_F9=120;//兼容IE和Firefox獲得keyBoardEvent對象varevt=(evt)?evt:((window.event)?window.event:"");//兼容IE和Firefox獲得keyBoardEvent對象的鍵值varkey=evt.keyCode?evt.keyCode:evt.which;if(evt.ctrlKey){if(appender.visible){appender.hide();appender.visible=false;log4javascript.setEnabled(false);}else{log4javascript.setEnabled(true);appender.show();appender.visible=true;}}};2、引入log4javascript.js和log4js3、使用log4javascript記錄日志$(function(){$("#Button1").click(function(){logger.debug("Thisisadebuggingmessagefromthelog4javascriptin-pagepage");logger.info("infoinfo");logger.error("errorinfo");});});
網(wǎng)站導(dǎo)航
- zblogPHP模板zbpkf
- zblog免費(fèi)模板zblogfree
- zblog模板學(xué)習(xí)zblogxuexi
- zblogPHP仿站zbpfang