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 Wed, 15 Dec 2004 00:45:31 GMT
At 04:15 PM 12/14/2004 -0600, you wrote:
 >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?
 >

I think you are reading my reply way too specifically.  What I tried to 
tell you was that your logger naming can be that of your choosing.  My 
example used a naming scheme that was intuitive and easy to remember.  If 
your folder structure doesn't lend itself to this type of naming, then 
using another naming scheme of your choice.  It can be anything you 
want.  What I am trying to stress is that counting on the value returned by 
this.getClass().getName() for a JSP is not a good idea because it is not 
intuitive and is not consistent across servers.  Even if you figure that 
you'll never move servers, you never know if the naming scheme will change 
in the next server version.  There is no guarantee.

As far as getting no logging currently, you might want to do a 
System.out.println() of this.getClass().getName() just to see what it is 
naming the class.  If you know that, then you should be able to configure 
properly if you've named your loggers in this fashion.


Jake


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


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