[QFJ-214] Does SLF4J/Log4J combo ignore changes to the log4j.properties file? Created: 21/Jul/07  Updated: 27/Jul/07  Resolved: 27/Jul/07

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.2.1
Fix Version/s: None

Type: Other Priority: Default
Reporter: Toli Kuznets Assignee: Steve Bate
Resolution: Fixed Votes: 0
Labels: None


 Description   

I have an app that's using SLF4JLogFactory and i have the slf4j-logj4 jar in the path, so in the end it's using log4j to print log messages.

The entries in the log4j.properties file are parsed and used when the app starts up, so whatever i have setup drives the filtering of the output.
However, if i modify the log4j file after the app starts up, the changes never take effect - the same messages get printed, regardless of whether or not i turn certain categories on/off.

Anybody else seeing something similar? I couldn't trace through in the QFJ code where that would make a difference - seems that SLF4J/Log4J would handle that on their own.

Just wondering if maybe we are not setting SLF4J/Log4J up correctly.



 Comments   
Comment by Jörg Thönnes [ 21/Jul/07 ]

Toli, I think this behaviour is standard. We use plain log4j in our processes and log4j reads
the config once at startup.

On the other hand, e.g. the JBoss app server refreshes properties regularly.

Actually, this depends how log4j is used programmatically. I remember some methods / classes in the API
to support this, but at moment I forgot where they are...

So I guess this should be handled inside the SL4J adapter code. Did you check whether they support some
config do enable this?

Cheers, Jörg

Comment by Brad Harvey [ 23/Jul/07 ]

Jörg is correct. I think you need to use http://logging.apache.org/log4j/docs/api/org/apache/log4j/PropertyConfigurator.html#configureAndWatch(java.lang.String) to make it reread the property file. I suspect you can just do this first thing in your application.

It should not be QFJ that does this though unless it is optional - otherwise other environments that already do this (eg, JBoss) might not behave as expected.

Cheers,
Brad.

Comment by Steve Bate [ 27/Jul/07 ]

Toli, I agree with Brad's comments. Does that approach sound OK to you?

Comment by Toli Kuznets [ 27/Jul/07 ]

Hmm, i think we are using conifgureAndWatch in our app ourselves (we use Log4J directly): http://trac.marketcetera.org/trac.fcgi/browser/platform/trunk/core/src/main/java/org/marketcetera/core/LoggerAdapter.java#L41

but it's been over a year since i've touched or looked at the logging code, so maybe there's some weird interplay of how we start the log4j and how QFJ does the same through SLF4J.

but it does sound like something is incorrect in our own setup. i'll investigate a bit more and let you guys know. thanks for the advice.

Generated at Sat Nov 23 10:29:11 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.