01: /*
02: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
03: *
04: * This file is part of Resin(R) Open Source
05: *
06: * Each copy or derived work must preserve the copyright notice and this
07: * notice unmodified.
08: *
09: * 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;
37: import java.util.logging.Logger;
38:
39: /**
40: * Environment-specific java.util.logging.Logger configuration.
41: */
42: public class LoggerAdmin extends AbstractManagedObject implements
43: LoggerMXBean {
44: private static final L10N L = new L10N(LoggerAdmin.class);
45:
46: private final Logger _logger;
47: private final ClassLoader _loader;
48: private Level _level;
49:
50: LoggerAdmin(Logger logger) {
51: _logger = logger;
52:
53: _loader = Thread.currentThread().getContextClassLoader();
54: }
55:
56: /**
57: * Sets the name of the logger to configure.
58: */
59: public String getName() {
60: return _logger.getName();
61: }
62:
63: /**
64: * Sets the output level.
65: */
66: public void setLevel(String levelName) {
67: Level level;
68:
69: if (levelName.equals("off"))
70: level = Level.OFF;
71: else if (levelName.equals("severe"))
72: level = Level.SEVERE;
73: else if (levelName.equals("warning"))
74: level = Level.WARNING;
75: else if (levelName.equals("info"))
76: level = Level.INFO;
77: else if (levelName.equals("config"))
78: level = Level.CONFIG;
79: else if (levelName.equals("fine"))
80: level = Level.FINE;
81: else if (levelName.equals("finer"))
82: level = Level.FINER;
83: else if (levelName.equals("finest"))
84: level = Level.FINEST;
85: else if (levelName.equals("all"))
86: level = Level.ALL;
87: else
88: throw new IllegalArgumentException(
89: L
90: .l(
91: "`{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 getLevel() {
96: return null;
97: }
98: }
|