You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Sheila Drummer <Sh...@cusys.edu> on 2002/04/15 18:30:51 UTC

questions about XML file and multiple output files

I have a question about getting a log4j.xml file to work.  Currently I'm
using the log4j.properties files. I would like to use an xml file instead,
but I don't know how to get it to work. I took out the log4j.properties file
from WEB-INF/classes and put in an log4j.xml at WEB-INF/classes/, but I
can't get it to recognize it and give me output. I'm executing a JSP and
then additionally I put code in the bean to get info into a file. It works
using a log4j.properties file, but not with a log4j.xml file.  I'm using the
log4j 1.1.3 version and Tomcat Version 3.2.4. 
A second question I have is when using the log4j.properties file, how do I
get multiple applications to write to their own separate files? If the
solution is to set up separate properties files, how do I get the
application recognized by the file?  I've been reading the API and other
info about using NDC as a means of accomplishing this, but I can't figure
out what to do with it. I copied in the following sample code and got it to
compile, but I don't know how or where to use it in conjunction with my JSP:

import org.apache.log4j.*;
public class TestNDC {
// !Make sure log4j.properties file exists in classpath
static Category cat = Category.getInstance(TestNDC.class.getName());
public static void main(String[] args) {
// Nested Diagnostic Configurator to identify the client for
// multithreaded client request processors such as servlets, if needed
NDC.push("Client #45890");
cat.info("Testing Nested Diagnostic Context (NDC).");
cat.info("Make sure %x is in layout pattern!");
cat.info("Client #45890 should appear in this log message.");
switchNDC();
cat.info("Finished.");
}
static void switchNDC() {
NDC.push("Client #99999");
cat.debug("Client #99999 should appear nested in this log message.");
NDC.pop();
}
}

Any help would be greatly appreciated.

Sheila

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>