logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hanson, Bryan" <bryan.han...@medtronic.com>
Subject RE: Log File by java package and jsp package not working
Date Tue, 14 Dec 2004 22:15:31 GMT
yes, but we are stuck with the folder structure we have, cannot change it.

Though we will be using BEA for awhile, no plans on changing it...so if we can stick with
a particular webserver, could we then (somehow) make the logger able to determine servlet
to log for?





-----Original Message-----
From: Jacob Kjome [mailto:hoju@visi.com]
Sent: Tuesday, December 14, 2004 4:02 PM
To: Log4J Users List
Subject: RE: Log File by java package and jsp package not working



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
implementation.

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...

hello.jsp
admin/manage.jsp
admin/another.jsp
help/howto.jsp

The loggers might be, respectively, named...

com.mycompany.jsp.Hello
com.mycompany.jsp.admin.Manage
com.mycompany.jsp.admin.Another
com.mycompany.jsp.help.HowTo

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"/>
  </logger>


Make sense?

Jake


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


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


Mime
View raw message