logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject RE: Log File by java package and jsp package not working
Date Tue, 14 Dec 2004 22:02:29 GMT

Your loggers need not be named for their class.  In fact, for JSP's you can't
count on any particular naming scheme for the generated class.  I'm pretty sure
that is entirely implementation specific, so the class name generated for
"hello.jsp" maybe jsp_servlet_hello.java on Tomcat and hello_jsp_servlet.java
on Weblogic (I made these names up, but you get the point).  If you start
counting on one naming scheme, you will quickly find yourself tied to a server

I suggest coming up with a standard naming scheme for your JSP's.  For instance,
have them all be within some common base fake package and, maybe have folder
names further distinguish the package.  Then, have the final name of the logger
itself be the name of the file (less ".jsp").  For instance, with the base
package "com.mycompany.jsp" and the following files...


The loggers might be, respectively, named...


You'd do this by passing in these names rather than this.getClass().getName() to
the getLogger() method such as....

Logger logger = Logger.getLogger("com.mycompany.jsp.admin.Manage");

Your config, in order to display logger output for the "admin" package only,
would be...

  <logger name="com.mycompany.jsp.admin" additivity="false">
   <level value="info"/>
   <appender-ref ref="JSPAdmin"/>

Make sense?


Quoting "Hanson, Bryan" <bryan.hanson@medtronic.com>:
> I'm using log4J in a JSP with taglibs-log.  I'm trying to configure the
> log4j.xml such that it will put the JSP log message in a particular log file
> based on the JSP/servlet package.  So far, I have not been successful.
> Does anyone have ideas how to configure a log4j.xml to log JSP messages to
> package based log files?
>  <logger name="jsp_servlet._capa" additivity="false">
>   <priority value="info"/>
>   <appender-ref ref="JSPcapa"/>
>  </logger>
> We have "capa" directory with JSP pages in it.  The webserver compiles the
> jsp to jsp_servlet\_capa with the class package: package jsp_servlet._capa

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message