KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > util > log4j > Log4jMgr


1 package de.webman.util.log4j;
2
3 import de.webman.util.registry.Manager;
4 import de.webman.util.registry.RegistryException;
5 import de.webman.util.log4j.WebmanCategory;
6 import org.apache.log4j.*;
7 import org.apache.log4j.xml.DOMConfigurator;
8 import java.io.PrintStream JavaDoc;
9 import java.io.File JavaDoc;
10
11
12 /**
13  * A registry which initializes and setups the log4j logging facility.
14  * Should be registered and loaded on start before any other registry.
15  *
16  * @author <a HREF="mailto:gregor@webman.de">Gregor Klinke</a>
17  * @version $Revision: 1.2 $
18  **/

19 public class Log4jMgr
20     implements Manager
21 {
22     /* $Id: Log4jMgr.java,v 1.2 2002/04/12 15:00:32 gregor Exp $*/
23
24     /**
25      * the constructor, only to be used by the Log4jMgrFactory
26      * @param basedir the directory to read the configuration from
27      **/

28     Log4jMgr(String JavaDoc basedir) {
29         /* since log4j is not setup yet, use standard out for logging */
30         PrintStream JavaDoc stdout = System.out;
31
32         /* set the file appender */
33         WebmanRollingFileAppender.setDocRoot(basedir);
34         
35         DOMConfigurator.configure(new File JavaDoc(basedir, "WEB-INF/classes/log4j.xml").toString());
36         Category root = Category.getRoot();
37         
38         // eigene Log4j Category setzen !
39
root.getDefaultHierarchy().setCategoryFactory(WebmanCategory.factory);
40         
41         stdout.println("Log4jRegistry: logging facility successfully setup");
42     }
43 }
44
Popular Tags