I've read all the articles and tried all the solutions. I think my issue is that JBoss is parsing my log4j.xml file at startup and not at run time. I have a j2ee interface that is called by the users. I have the following in my class:
When the class is called. I expected the setProperty to store the path and then when I create my logger, for it to read the log4j.xml and parse the correct path name. but that's not what happens, I get a null pointer and no logs.
if I change the property to the JBoss server log directory, all is well and I get my log file.
I do NOT want my log file in the JBoss default folder.
So, my question, is there a way to force JBoss to reload my log4j.xml, is that the right approach, is it thread safe, and how costly is it. I expect this interface to get moderate to heavy usage and reloading the xml each time could bring the systems to it's knees.
Basically, I need to set the system property before anything else does, so the above approach makes sure that I call a servlet right off the bat that has my set properties in it.
This worked like a champ!
Joined: Jun 28, 2012
Thanks for the reply WP,
I was trying to figure out a solution where I controlled everything in my app. I did not want to get my system admins involved as it takes days to get anything out of them.
Basically, the log4j.xml is only ready one once the first time your app is accessed. Since my test client was not the first call, the xml had already been loaded. The solution I posted above forces a servlet to execute first before anything else does and I can load my system property at that time.