View Javadoc

1   /*
2    ~ Copyright 2006-2007 Nicolas De Loof.
3    ~
4    ~ Licensed under the Apache License, Version 2.0 (the "License");
5    ~ you may not use this file except in compliance with the License.
6    ~ You may obtain a copy of the License at
7    ~
8    ~      http://www.apache.org/licenses/LICENSE-2.0
9    ~
10   ~ Unless required by applicable law or agreed to in writing, software
11   ~ distributed under the License is distributed on an "AS IS" BASIS,
12   ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   ~ See the License for the specific language governing permissions and
14   ~ limitations under the License.
15   */
16  package org.jmonit.log;
17  
18  import org.apache.commons.logging.LogFactory;
19  
20  /**
21   * <code>Logger</code> implementation based on jakarta commons-logging.
22   * <p>
23   * Please notice commons-logging configuration is out of scope of jMonit runtime
24   * discovery. If you get troubles using commons-logging, read the doc at
25   * {http://jakarta.apache.org/commons/logging} and/or use the diagnostic mode of
26   * commons-logging 1.1 to check for classloaders conflicts.
27   * 
28   * @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
29   */
30  public class CommonsLoggingLogger
31      extends Log
32  {
33  
34      /** Commons-logging delegate */
35      private org.apache.commons.logging.Log log;
36  
37      /**
38       * Constructor
39       * 
40       * @param caller target logging class
41       */
42      public CommonsLoggingLogger( Class caller )
43      {
44          super();
45          log = LogFactory.getLog( caller );
46      }
47  
48      /**
49       * {@inheritDoc}
50       * 
51       * @see info.jmonit.logger.Log#isDebugEnabled()
52       */
53      public boolean isDebugEnabled()
54      {
55          return log.isDebugEnabled();
56      }
57  
58      /**
59       * {@inheritDoc}
60       * 
61       * @see info.jmonit.logger.Log#debug(java.lang.String)
62       */
63      public void debug( String message )
64      {
65          log.debug( message );
66      }
67  
68      /**
69       * {@inheritDoc}
70       * 
71       * @see info.jmonit.logger.Log#info(java.lang.String)
72       */
73      public void info( String message )
74      {
75          log.info( message );
76      }
77  
78      /**
79       * {@inheritDoc}
80       * 
81       * @see info.jmonit.logger.Log#info(java.lang.String, Throwable)
82       */
83      public void info( String message, Throwable t )
84      {
85          log.info( message, t );
86      }
87  
88      /**
89       * {@inheritDoc}
90       * 
91       * @see info.jmonit.logger.Log#error(java.lang.String)
92       */
93      public void error( String message )
94      {
95          log.error( message );
96      }
97  
98      /**
99       * {@inheritDoc}
100      * 
101      * @see info.jmonit.logger.Log#error(java.lang.String, Throwable)
102      */
103     public void error( String message, Throwable t )
104     {
105         log.error( message, t );
106     }
107 
108     /**
109      * {@inheritDoc}
110      * 
111      * @see info.jmonit.logger.Log#warn(java.lang.String)
112      */
113     public void warn( String message )
114     {
115         log.warn( message );
116     }
117 
118     /**
119      * {@inheritDoc}
120      * 
121      * @see info.jmonit.logger.Log#warn(java.lang.String, Throwable)
122      */
123     public void warn( String message, Throwable t )
124     {
125         log.warn( message, t );
126     }
127 }