KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > log > Log


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2004 France Telecom R&D
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  * Authors: S.Chassande-Barrioz.
25  *
26  */

27
28 package org.objectweb.speedo.log;
29
30 import org.objectweb.util.monolog.api.LoggerFactory;
31 import org.objectweb.util.monolog.api.Logger;
32 import org.objectweb.util.monolog.Monolog;
33
34 /**
35  * Logging system initialisation.
36  * By default, the loggerFactory class is <code>org.objectweb.util.monolog.wrapper.log4j.MonologLoggerFactory</code>
37  * @author S.Chassande-Barrioz
38  */

39 public class Log
40         implements LoggerFactory, LogAttributes {
41
42     /**
43      * Default name of the logger factory
44      */

45     public final static String JavaDoc DEFAULT_LOGGER_FACTORY =
46             "org.objectweb.util.monolog.wrapper.printwriter.LoggerImpl";
47
48     private static LoggerFactory lastLF = null;
49
50     public static LoggerFactory getLoggerFactory() {
51         if (lastLF == null) {
52             lastLF = Monolog.initialize();
53         }
54         return lastLF;
55     }
56
57     private LoggerFactory delegate = null;
58     private String JavaDoc pfn = null;
59
60     // IMPLEMENTATION OF THE LogAttributes INTERFACE //
61
//-----------------------------------------------//
62

63     public String JavaDoc getPropertiesFileName() {
64         return pfn;
65     }
66
67     public void setPropertiesFileName(String JavaDoc propfn) {
68         if (pfn != null && pfn.equals(propfn))
69             return;
70         pfn = propfn;
71         delegate = Monolog.getMonologFactory(propfn);
72         lastLF = this;
73     }
74
75     // IMPLEMENTATION OF THE LoggerFactory INTERFACE //
76
//-----------------------------------------------//
77

78     public Logger getLogger(String JavaDoc s) {
79         return delegate.getLogger(s);
80     }
81
82     public Logger getLogger(String JavaDoc s, String JavaDoc s1) {
83         return delegate.getLogger(s1);
84     }
85
86     public String JavaDoc getResourceBundleName() {
87         return delegate.getResourceBundleName();
88     }
89
90     public void setResourceBundleName(String JavaDoc s) {
91         delegate.setResourceBundleName(s);
92     }
93
94     public Logger[] getLoggers() {
95         return delegate.getLoggers();
96     }
97 }
98
Popular Tags