Join the DZone community and get the full member experience.Join For Free
// 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(// 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.
Opinions expressed by DZone contributors are their own.