Reputation: 223
I am using Log4js Library to print the log message in a file. In that I am getting 2 issues. Such as:
12:00:40 PM ERROR Log4js - TypeError: netscape.security.PrivilegeManager is undefined
in Non-IE Browser. Please tell me how to fix this exception. While Using IE , It's
working fine.CATALINA_HOME
in the JavaScript part. I am using Tomcat.
To get this CATALINA_HOME
in Log4j, we need to write as follow
log4j.appender.FILE.File=${catalina.base}/logs/MyLogs.log
.
If I'll write the catalina.base, not working in the JavaScript. Here is my code please have a look on my code and detect the error causing line to have the solution:
<script type="text/javascript">
function myFunction(name) {
var date = new Date();
var log = Log4js.getLogger("fileAppender");
log.setLevel(Log4js.Level.ALL);
var toAppend=date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
var fileAppender = new Log4js.FileAppender("${catalina.base}\\logs\\JSLogging."+toAppend+".log");
log.addAppender(fileAppender);
log.debug("My Debugging");
log.info("My Information");
}
</script>
Upvotes: 0
Views: 1947
Reputation: 164
try adding <script type="text/javascript" src="log4javascript.js"></script>
in the code seems it is not able to get the reference of the main script.
see if this can help you
<script type="text/javascript">
// Create the logger
var log = log4javascript.getLogger();
// Create a PopUpAppender with default options
var popUpAppender = new log4javascript.PopUpAppender();
// Change the desired configuration options
popUpAppender.setFocusPopUp(true);
popUpAppender.setNewestMessageAtTop(true);
// Add the appender to the logger
log.addAppender(popUpAppender);
// Test the logger
log.debug("Hello world!");
</script>
enter code here
use this link
Upvotes: 1