Cool! That warning has always bugged me a bit, but not enough to spend any time thinking about the cause and solution. Thanks for the heads-up Craig!

Frank

Craig McClanahan wrote:
If you do this in a ServletContextListener's contextInitialized()
method you won't get the warnings, because this fires before
ActionServlet starts up.

Craig


On Wed, 16 Feb 2005 17:27:14 -0500, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:

You can configure Log4J from a Struts plugin, although you will get a
configuration warning when Struts starts up before the plugin fires.
Here's some init code I've used (roughly... I don't actually use init
parameters and I construct a real path from a virtual path, and I do
some other hackery of the config file on-the-fly, so this is trimmed
down a bit, but I think it's close to what you want)...

String lConfigFile = servlet.getInitParameter("pathToLog4JConfigFile");
FileReader fr = new FileReader(lConfigFile);
BufferedReader br = new BufferedReader(fr);
StringBuffer sbXML = new StringBuffer();
String line = "";
while ((line = br.readLine()) != null) { sbXML.append(line); }
br.close();
String xml = sbXML.toString();
InputStream isXML = new ByteArrayInputStream(xml.getBytes());
new DOMConfigurator().doConfigure(isXML, LogManager.getLoggerRepository());
Category cat = Category.getInstance(getClass().getName());
cat.info("Log4J initialized");

Might not be the prettiest, but it works.

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

Ye, Young wrote:

yes, you can.

-----Original Message-----
From: Brian McGovern [mailto:[EMAIL PROTECTED]
Sent: 2005/02/16 4:48 PM
To: Struts Users Mailing List
Subject: log4j struts


I want to use log4j with my struts app. Can I use the struts-config.xml to specify log4j as an init parameter and point it to its external properties file? Or do i have to make my own front controller servlet for that?

thanks


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






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








-- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com


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



Reply via email to