KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > logging > JDK14LoggerPlugin


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.logging;
8
9 import java.util.logging.Logger JavaDoc;
10 import java.util.logging.Level JavaDoc;
11
12 /** An example LoggerPlugin which uses the JDK java.util.logging framework.
13  *
14  * @author Scott.Stark@jboss.org
15  * @version $Revison:$
16  */

17 public class JDK14LoggerPlugin implements LoggerPlugin
18 {
19    private Logger log;
20
21    public void init(String JavaDoc name)
22    {
23       log = Logger.getLogger(name);
24    }
25
26    public boolean isTraceEnabled()
27    {
28       return log.isLoggable(Level.FINER);
29    }
30
31    public void trace(Object JavaDoc message)
32    {
33       log.finer(message.toString());
34    }
35
36    public void trace(Object JavaDoc message, Throwable JavaDoc t)
37    {
38       log.log(Level.FINER, message.toString(), t);
39    }
40
41    public boolean isDebugEnabled()
42    {
43       return log.isLoggable(Level.FINE);
44    }
45
46    public void debug(Object JavaDoc message)
47    {
48       log.fine(message.toString());
49    }
50
51    public void debug(Object JavaDoc message, Throwable JavaDoc t)
52    {
53       log.log(Level.FINE, message.toString(), t);
54    }
55
56    public boolean isInfoEnabled()
57    {
58       return log.isLoggable(Level.INFO);
59    }
60
61    public void info(Object JavaDoc message)
62    {
63       log.info(message.toString());
64    }
65
66    public void info(Object JavaDoc message, Throwable JavaDoc t)
67    {
68       log.log(Level.INFO, message.toString(), t);
69    }
70
71    public void warn(Object JavaDoc message)
72    {
73       log.warning(message.toString());
74    }
75
76    public void warn(Object JavaDoc message, Throwable JavaDoc t)
77    {
78       log.log(Level.WARNING, message.toString(), t);
79    }
80
81    public void error(Object JavaDoc message)
82    {
83       log.severe(message.toString());
84    }
85
86    public void error(Object JavaDoc message, Throwable JavaDoc t)
87    {
88       log.log(Level.SEVERE, message.toString(), t);
89    }
90
91    public void fatal(Object JavaDoc message)
92    {
93       log.severe(message.toString());
94    }
95
96    public void fatal(Object JavaDoc message, Throwable JavaDoc t)
97    {
98       log.log(Level.SEVERE, message.toString(), t);
99    }
100 }
101
Popular Tags