Welcome to the new Spring.io forums!
If this is your first visit, be sure to check out the
by clicking the link above, and for security reasons, use the
forgot password link to reset your password..
You may have to register before you can post: click the register
link above to proceed. To start viewing messages, select the forum that you want to visit
from the selection below.
No announcement yet.
how to initialize log4J system...Page Title Module
Configuring Log4J within Spring RichClient Application
you have two options:
- do it programatically in main(), before you even create the ApplicationLauncher
- do it the usual way, i.e. provide a log4j.xml in the root of the classpath.
Log4J has an "default initialisation sequence" which is triggered by loading org.apache.log4j.LogManager . Normally, you don't need to to this manually, just issue the first Logger.getLogger("xyz") and this initialisation is triggered. And because already the Spring RichClient framework code uses logging (via the commons.logging facade), you need to have the configuration in place before starting your app. See http://logging.apache.org/log4j/1.2/manual.html (look for "Default Initialization Procedure").
Normally, you should prefer the "usual way" via a log4j configuration file. But doing the configuration hard wired (programmatically) can be helpful in the following situations:
- you want to switch off Logging altogether
- you just want to provide a very basic config and won't ever want to configure it in more detail
- you want to capture all log messages and forward them to some server process (highly recommended if you write a distributed client-server app with many clients)
Hint: the most simple thing is to silence log4j altogether. You can do it as follows:
for very simplistic logging, instead of a NullAppender, you add a ConsoleAppender or a simple file appender. But my recommendation is: look in the log4j doku and learn how to configure it, that's very usefull knowledge