I'm fairly new to
Java and completely new to log4j. A consultant that we had in recently strongly recommended that we use log4j. (Up until this point I just used system.out when I needed to log a message). I've been meaning to look into it, but he convinced me to do it now. So, I did a lot of reading trying to get an idea of the best way to set things up, but I'm still not sure how to begin. Right now we have two java applications running on
JBoss. Eventually, we will have many java applications so I would really like to set this up right from the start.
The consultant recommended a separate log for each application and he recommended that we use a separate log4j.xml within each application to control the logging for that application. In that case, I believe the log4j.xml would be within each jar/war/ear. To me that sounds like a bad idea. If you need to change the logging config, you need to recompile/redeploy.
I understand that we could put all the configuration into the jboss-log4j.xml, but I read that if I need to change the logging for one application, by changing the 'master file', it will affect all the applications currently using that file and will affect performance.
Can/should I have multiple log4j.xml files on the server, outside of my application/war? What do I name them so they will be recognized?
My other question concerns the migration from testing/development to production. During development I would assume I would have a lot of logging going on to troubleshoot and work through issues. But in production I would want much less logging. How do I handle that? Do I need to remember to change the logging levels in log4j.xml prior to deploying in production? What is the best way to handle that?
(I should mention that we don't have a clearly defined process for moving between development, qa, production yet - but that's another whole subject entirely.)
Any help, info, pointers, experiences are welcome! Thanks!