<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: initialization code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 06:17:38 GMT</pubDate>
    <description>DZone Snippets: initialization code</description>
    <item>
      <title>Java: log4j Initialization Example</title>
      <link>http://snippets.dzone.com/posts/show/4013</link>
      <description>// Initialization for Basic Console Output&lt;br /&gt;// Ref: http://logging.apache.org/log4j/docs/manual.html&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt; import com.foo.Bar;&lt;br /&gt;&lt;br /&gt; // Import log4j classes.&lt;br /&gt; import org.apache.log4j.Logger;&lt;br /&gt; import org.apache.log4j.BasicConfigurator;&lt;br /&gt;&lt;br /&gt; public class MyApp {&lt;br /&gt;&lt;br /&gt;   // Define a static logger variable so that it references the&lt;br /&gt;   // Logger instance named "MyApp".&lt;br /&gt;   static Logger logger = Logger.getLogger(MyApp.class);&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;&lt;br /&gt;     // Set up a simple configuration that logs on the console.&lt;br /&gt;     BasicConfigurator.configure();&lt;br /&gt;&lt;br /&gt;     logger.setLevel(Level.DEBUG); // optional if log4j.properties file not used&lt;br /&gt;     // Possible levels: TRACE, DEBUG, INFO, WARN, ERROR, and FATAL&lt;br /&gt;&lt;br /&gt;     logger.info("Entering application.");&lt;br /&gt;     Bar bar = new Bar();&lt;br /&gt;     bar.doIt();&lt;br /&gt;     logger.info("Exiting application.");&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 14 May 2007 09:44:45 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4013</guid>
      <author>thitiv (Thiti V. Sintopchai)</author>
    </item>
  </channel>
</rss>
