Log4j and jsp
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   prachi_jain
Posted On:   Thursday, October 3, 2002 07:17 AM

Test Hiii All, First of all, i m happy to see the forum for Log4j. Thanks. I am trying to use Log4j with jsps. I am using the log taglib from jakarta along with Log4j. I wants to do the logging for any kind of exceptions also. I tried to use the log tags in expection. But, it didn't work. Here is what i m using. What can be the problem with this. Moreover, i have kept my Log4j.properties in my java classes path. <%@ taglib uri="http://jakarta.apache.org/taglibs/log-1.0" prefix="log" %> <%@ page session = "false"%> <% try{ }catch(Exception ex){ %>    More>>
Test

Hiii All,


First of all, i m happy to see the forum for Log4j. Thanks.
I am trying to use Log4j with jsps. I am using the log taglib from jakarta along with Log4j.


I wants to do the logging for any kind of exceptions also. I tried to use the log tags in expection. But, it didn't work.



Here is what i m using. What can be the problem with this. Moreover, i have kept my Log4j.properties in my java classes path.

			

<%@ taglib uri="http://jakarta.apache.org/taglibs/log-1.0" prefix="log" %>




<%@ page session = "false"%>
<%

try{

}catch(Exception ex){
%>
<% ex.getMessage();%>
<%
}
%>




I have one more doubt?? How you are initialising Log4j while using with jsps. I tried to keep the Log4j.properties in myapp/web-inf/classes. But, i think that's not worked up.


In log4j properties i have set the level to info.
Let me tell you, where i have placed the files.If suppose test is my app. then,


I have placed the log.tld in
webapps estWEB-INFjsplog.tld


I have placed the jar files in
webapps estWEB-INFliblog.jar


I am getting the output in console and in file. But, i m not getting the exception info in file.


I am using TestLogging.java file for initialising log4j.

The following is the content of properties file:

			
# Sample properties to initialise log4j
log4j.rootCategory=info, stdout, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=C:\jakarta-tomcat-3.2.2\webapps\test\logtags.log

log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=2

log4j.appender.R.layout=org.apache.log4j.PatternLayout


Please guide me to solve out this problem.

regards    <<Less

Re: Log4j and jsp

Posted By:   Michael_Canzoneri  
Posted On:   Monday, October 7, 2002 11:46 AM

Sorry I haven't gotten back to you sooner. I am traveling and have limited access to my computer.



I am not sure of your situation/application but you might want to consider moving as much of your Java code out of your JSP and into your servlet. Like I said, I am not sure of what you are trying to accomplish but that would be my first recommendation. It has been my experience that a Model-2 approach may improve your application. We can talk about this more if you like. Look at my BIO, just click on my name at the top of the forum page, for my email (its at the bottom).



Maybe this little piece from my web.xml file might help with the initialization part.




log4j-init
com.example.shared.Log4jInit



log4j-init-file

log4j.lcf



1




Maybe that will help.


Michael

Re: Log4j and jsp

Posted By:   prachi_jain  
Posted On:   Monday, October 7, 2002 02:39 AM

Please Gurus,


help me settle out this problem??


Thanks
About | Sitemap | Contact