After commenting out, my test statement doesn't get printed. And before you ask: I checked if the levels are preserved i.e. if DEBUG > INFO > WARN > FATAL. Yet it is.
The file gets read, because if I provide wrong path it throws exception FileNotFound. So the path is good (How many times must I prove it). Also, in log4j documentation it's said only one log file can exist, so if there was another one somewhere else I would have gotten warning for trying to overwrite it. Furthermore. I am loading a config file with root logger as DEBUG like 2 lines before calling HttpClient. So even if there was some other config file, my root settings should overwrite it because a) they are root settings b) I set the settings 2 lines before executing HttpClient, so the system has no possibility to load OTHER settings. Another proof: And if there WERE predefined settings for HttpClient that ARE impossible to override, then why would HttpClient provide logging interface at all? That was an ad absurdum proof. So, why it doesn't work at all? and btw. log4j.properties is NOT in classpath and never will be. That's why I use PropertyConfigurator.configure(POINTING_TO_THE_F***_FILE); And before you ask, I did so prior to using propertyConfigurator - the properties file was in "src" a'ka "default package". But: 1. It didnt work 2. Why am I being FORCED to use <Default package> ??? it's bad programming style. AND I have seen log4j working somewhere else without that forced bound. So it CAN work. But it DOESN'T with HttpClient. How much more must I emphasize that? On 10 April 2012 13:42, Ryan Smith <[email protected]> wrote: > It is possible that your app might be reading a log4j config file somewhere > in a jar. If you want to test, try commenting out your > "PropertyConfigurator" line and see if your debug statement in your code > still works. My guess is your log4j.properties file isnt on your > CLASSPATH. Usually src folders arent on the CLASSPATH unless you add them > yourself. If all else fails, try adding the absolute file path of your > log4j.properties file to your CLASSPATH. > > hth, > -Ryan
