DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Log4j 101
// Once you have included the Log4j jar into the classpath of your
// application, you can use the following code within each class to
// get a logger for that class. That is, all log messages issued from
// within that class will be tagged with the classname to make it
// easier to locate a problem. See my tutorial on Log4j,
// Log4j in 30 Minutes or Less (http://www.johnmunsch.com/projects/Presentations/)
// for a better introduction.
private static Logger log = Logger.getLogger(<class name>.class);
// When you need to specify the location (or a different name) for // the log.properties file, you can set a specific System variable // which Log4j will be guaranteed to read as soon as any part of // your code tries to use it. You do that by passing the following // to the JVM as you start your Java application.
-Dlog4j.configuration=file:<path to log.properties file>





