Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Log4j 101

DZone's Guide to

Log4j 101

·
Free Resource
// 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);

  

// 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:
  

  
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}