Hello,

This is a question about a post from several weeks ago. I wasn't ready to try it at the time, but I saved it because I knew I'd need it later on ... :)

When I tried to use "filtering" as described in the original post (actually, I created a "filterset" inside the copy tag), it works fine except that on Windows 2K it contains back-slashes(\) from my $CATALINA_HOME env variable and forward-slashes(/) from the subpath info inside of Ant. Then, when log4j gets it, the backslashes are effectively ignored (probably interpreted as "escaping" the next character) so log4j complains that no such directory exists.

Is there a way to get log4j to accept either path-separator character, or alternately is anyone aware of an Ant function to force "filtering" to use the platform-dependent path separator when replacing text ??

My Ant build.xml looks basically like this:

<property name="installdir" value="${env.CATALINA_HOME}/webapps/MYAPP"/>

        <target ...>
          <copy todir=${build}/WEB_INF/classes"
                 file="${basedir}/config/log4j.xml">
            <filterset>
              <filter type="INSTALLDIR" value="${installdir>/WEB_INF/>
            </filterset>
          </copy>
        </target>

And my log4j.xml looks roughly like this:

        <appender name="XYZ"
                class="... RollingFileApppender">
          <param name="file" value="@INSTALLDIR@/myapp.log/>
          .....
        </appender>

In the destination log4j.xml file, the value for the appender's "file" param is "C:\Java\tomcat/webapps/MYAPP/WEB_INF/myapp.log". Any thoughts ???

--- regards ---
Larry


At 01:54 PM 8/5/03 -0400, Shapira, Yoav wrote:


Howdy,
This is a common problem, and you have several options.

>The logging works fine. The problem is specifying the location of the
log
>file.
>I use log4j.xml to configure log4j. In there I have to specify the
location
>of the
>log file as absolute path. This creates a problem because we have to
edit

You don't have to specify the path as absolute: it can be relative (to
the working directory), and it can contain environment variables.

>log4j.xml
>during each deployment of our application to edit the location of the
log
>file.

Another option is to automate this by copying the log4j.xml file with
filtering="true" in Ant.  In log4j.xml you'd have a token value for the
log file path, e.g. @logFilePath@, and when deploying you'd have Ant
replace this value with a value coming from an Ant property.

>I attempted to solve the problem by adding the following code in a
utility
>class
>
>               rootLogger = Logger.getRootLogger();
>               FileAppender fp = (FileAppender)
>rootLogger.getAppender("LOGFILE");

This is yet another option, the pure programmatic way.  I find this
useful some time, but cleaner if you create the appender
programmatically as well, i.e.
Layout l = ...
String logFilePath = ....
Appender app = new FileAppder(l, logFilePath);
Logger.getRootLogger().addAppender(app)

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]

--------------------------
Larry Young
The Dalmatian Group
www.dalmatian.com




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



Reply via email to