KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > grlea > log > test > slf4j > SimpleSlf4jLoggingClass


1 package org.grlea.log.test.slf4j;
2
3 // $Id: SimpleSlf4jLoggingClass.java,v 1.2 2006/07/13 12:44:55 grlea Exp $
4
// Copyright (c) 2004-2006 Graham Lea. All rights reserved.
5

6 // Licensed under the Apache License, Version 2.0 (the "License");
7
// you may not use this file except in compliance with the License.
8
// You may obtain a copy of the License at
9
//
10
// http://www.apache.org/licenses/LICENSE-2.0
11
//
12
// Unless required by applicable law or agreed to in writing, software
13
// distributed under the License is distributed on an "AS IS" BASIS,
14
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
// See the License for the specific language governing permissions and
16
// limitations under the License.
17

18 import org.grlea.log.SimpleLog;
19 import org.grlea.log.SimpleLogger;
20
21 import org.apache.commons.logging.LogFactory;
22 import org.apache.commons.logging.Log;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 /**
27  * <p></p>
28  *
29  * @author Graham Lea
30  * @version $Revision: 1.2 $
31  */

32 public class
33 SimpleSlf4jLoggingClass
34 {
35    private final Logger log;
36
37    public
38    SimpleSlf4jLoggingClass()
39    {
40       log = LoggerFactory.getLogger(getClass());
41    }
42
43    public
44    SimpleSlf4jLoggingClass(String JavaDoc loggerName)
45    {
46       log = LoggerFactory.getLogger(loggerName);
47    }
48
49    public Logger
50    getLogger()
51    {
52       return log;
53    }
54
55    public void
56    doSomeLogging()
57    {
58       log.error("Test of Error");
59       log.warn("Test of Warn");
60       log.info("Test of Info");
61       log.debug("Test of Debug");
62    }
63
64    public void
65    logAnError()
66    {
67       log.info("Test of Exception", new Throwable JavaDoc("Test Message"));
68    }
69 }
Popular Tags