With Log4j you have several options: a properties file, a xml file, or java
properties. The first two, you must open up a FileInputStream, therefore
you must provide the location of the file. That works great if you are
using Windows but with Unix the structure is a bit different plus I wanted
to have everything in a war file. I tried jarring it up and using java.io
via jarinputstream to read the file, etc. Major headache. The easiest way
was to place the info into a constants file, obviously not the best way
since you have to hard code. For me if I have to hard code something it
sits in a constants file.
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.*;
import org.apache.log4j.Category.*;
eg:
this.serviceProperties = new Properties();
this.serviceProperties.setProperty("log4j.rootCategory",com.Constants.ROOT_C
ATEGORY);
this.serviceProperties.setProperty("log4j.appender.A1",com.Constants.PowerCo
nstants.A1);
//this class from log4j does all the work involved in setting up the
file
PropertyConfigurator.configure(this.serviceProperties);
My constants file looks like this.
public final static String ROOT_CATEGORY = ", A1, A2";
public final static String A1 = "org.apache.log4j.FileAppender";
public final static String A1_FILE = "System.out";
Southin
-----Original Message-----
From: Miranda Carlos [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 16, 2001 11:13 AM
To: [EMAIL PROTECTED]
Subject: RE: [JBoss-user] Jboss and Log4j
How ?
Thanks .-
-----Original Message-----
From: Simphoukham, Southin [ mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ]
Sent: Viernes, 13 de Abril de 2001 06:12 p.m.
To: '[EMAIL PROTECTED]'
Subject: RE: [JBoss-user] Jboss and Log4j
I solved the problem. Put everything into properties, hard code it to a
constants file.
-----Original Message-----
From: Simphoukham, Southin [ mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ]
Sent: Friday, April 13, 2001 11:04 AM
To: '[EMAIL PROTECTED]'
Subject: [JBoss-user] Jboss and Log4j
Does JBoss 2.2 integrate Log4J? Has anyone tried using it with JBoss? I
remember seeing a thread on it.
I am working on the logging portion of my application. It works great in
Windows NT and 2000. Once I port it over to Unix, Log4J cannot find the
configuration file. Ideally I would like to drop the configuration file
into a war file so I can just drop it into the deploy directory. My problem
now is how do I read the properties file from a war file and put it into an
inputstream.
Thanks,
Southin
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user
<http://lists.sourceforge.net/lists/listinfo/jboss-user>
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user
<http://lists.sourceforge.net/lists/listinfo/jboss-user>
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user