Howdy,

>initialization servlet  that goes through the log4j.properties file
>making all the file locations be relative to my web app directory. The
>code is listed below.

Consider putting this code in a ServletContextListener's
contextInitialized() method, instead of a servlet's init() method, as
the latter can get called multiple times at the container's behest.

>My questions are:
>- Is this a reasonable way of doing things?
>- Is there a better way?
<snip>

>    public void init() {
>        String prefix = getServletContext().getRealPath("/");

Keep in mind prefix will be null if you're running out of a packed .war
file.

>
>            for ( enum = props.propertyNames(); enum.hasMoreElements();
) {
>                pName = (String ) enum.nextElement();
>                if ( pName.startsWith("log4j.appender.") &&
>                     pName.endsWith(".File")) {

Instead of doing this whole property replacement scheme, why not just
specify a system-property based file name in your log4j configuration
file, e.g.
log4j.MyAppender.File=${CATALINA_HOME}/logs/myLog.txt

The above strategy and similar ones have been discussed on this list in
the past.  You can search the archives for more information and
examples.

Yoav Shapira




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to