KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > log > LoggerAdmin


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.log;
31
32 import com.caucho.management.server.AbstractManagedObject;
33 import com.caucho.management.server.LoggerMXBean;
34 import com.caucho.util.L10N;
35
36 import java.util.logging.Level JavaDoc;
37 import java.util.logging.Logger JavaDoc;
38
39 /**
40  * Environment-specific java.util.logging.Logger configuration.
41  */

42 public class LoggerAdmin extends AbstractManagedObject implements LoggerMXBean
43 {
44   private static final L10N L = new L10N(LoggerAdmin.class);
45
46   private final Logger JavaDoc _logger;
47   private final ClassLoader JavaDoc _loader;
48   private Level JavaDoc _level;
49
50   LoggerAdmin(Logger JavaDoc logger)
51   {
52     _logger = logger;
53
54     _loader = Thread.currentThread().getContextClassLoader();
55   }
56   
57   /**
58    * Sets the name of the logger to configure.
59    */

60   public String JavaDoc getName()
61   {
62     return _logger.getName();
63   }
64   
65   /**
66    * Sets the output level.
67    */

68   public void setLevel(String JavaDoc levelName)
69   {
70     Level JavaDoc level;
71     
72     if (levelName.equals("off"))
73       level = Level.OFF;
74     else if (levelName.equals("severe"))
75       level = Level.SEVERE;
76     else if (levelName.equals("warning"))
77       level = Level.WARNING;
78     else if (levelName.equals("info"))
79       level = Level.INFO;
80     else if (levelName.equals("config"))
81       level = Level.CONFIG;
82     else if (levelName.equals("fine"))
83       level = Level.FINE;
84     else if (levelName.equals("finer"))
85       level = Level.FINER;
86     else if (levelName.equals("finest"))
87       level = Level.FINEST;
88     else if (levelName.equals("all"))
89       level = Level.ALL;
90     else
91       throw new IllegalArgumentException JavaDoc(L.l("`{0}' is an unknown log level. Log levels are:\noff - disable logging\nsevere - severe errors only\nwarning - warnings\ninfo - information\nconfig - configuration\nfine - fine debugging\nfiner - finer debugging\nfinest - finest debugging\nall - all debugging",
92                          levelName));
93   }
94
95   public String JavaDoc getLevel()
96   {
97     return null;
98   }
99 }
100
Popular Tags