KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > notification > util > LogUtil


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1999-2004 Gerald Brose
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library 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  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */

21
22 package org.jacorb.notification.util;
23
24 import org.apache.avalon.framework.configuration.ConfigurationException;
25 import org.apache.avalon.framework.logger.LogKitLogger;
26 import org.apache.avalon.framework.logger.Logger;
27 import org.apache.log.Hierarchy;
28
29 /**
30  * @author Alphonse Bendt
31  * @version $Id: LogUtil.java,v 1.2 2005/03/31 20:10:43 alphonse.bendt Exp $
32  */

33 public class LogUtil
34 {
35     private static org.jacorb.config.Configuration sConfiguration_;
36
37     public static Logger getLogger(org.apache.avalon.framework.configuration.Configuration config, String JavaDoc name)
38     {
39         try {
40             return ((org.jacorb.config.Configuration)config).getNamedLogger(name);
41         } catch (ClassCastException JavaDoc e)
42         {
43             return getLogger(name);
44         }
45     }
46     
47     public static Logger getLogger(String JavaDoc name)
48     {
49         try
50         {
51             if (sConfiguration_ == null)
52             {
53                 sConfiguration_ = org.jacorb.config.Configuration.getConfiguration(null, null, false);
54             }
55             
56             return sConfiguration_.getNamedLogger(name);
57         } catch (ConfigurationException e)
58         {
59             return new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(name));
60         }
61     }
62 }
Popular Tags