This content has been marked as final.
Show 5 replies
-
-
2. Re: Web application logging
dciarnie May 1, 2008 1:29 PM (in response to dciarnie)Thanks but that doesn't look like it's what I want.
My application uses ServletContext.log() to write log messages which I don't want to change. What I would prefer is to be able to drop something in the application's WEB-INF or META-INF directory that does the equivalent of the Logger element and that does not require me to change my code.
Thanks,
Dan. -
3. Re: Web application logging
jaikiran May 2, 2008 11:38 AM (in response to dciarnie)Sorry, i haven't used the ServletContext.log API. And right now i dont have my local setup where i can try this. The javadoc mentions this
Writes the specified message to a servlet log file, usually an event log. The name and type of the servlet log file is specific to the servlet container.
Can you post a few lines of these logs from the server.log file? That might give someone here a hint as to where/how the configuration needs to be done. -
4. Re: Web application logging
dciarnie May 2, 2008 2:25 PM (in response to dciarnie)Here's a sample log entry:
2008-05-01 09:18:28,772 INFO \ [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/ws/v06]] log entry
The /ws/v06 is the context-root defined in the ear application.xml -
5. Re: Web application logging
jaikiran May 9, 2008 6:15 AM (in response to dciarnie)In the simplest form you can edit the jboss-log4j.xml and add the following:
<appender name="MYSERVLET_LOG" class="org.jboss.logging.appender.RollingFileAppender"> <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/> <param name="File" value="${jboss.server.log.dir}/myservlet.log"/> <param name="Append" value="false"/> <param name="MaxFileSize" value="500KB"/> <param name="MaxBackupIndex" value="1"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/> </layout> </appender> <category name="org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/ws/v06]"> <priority value="DEBUG"/> <appender-ref ref="MYSERVLET_LOG"/> </category>
If the context of the web app changes, then you will have to appropriately change the jboss-log4j.xml category too.