View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.log4j.spi;
18  
19  import org.apache.log4j.Appender;
20  import org.apache.log4j.Level;
21  import org.apache.log4j.Logger;
22  import org.apache.log4j.Priority;
23  
24  import java.util.Enumeration;
25  import java.util.ResourceBundle;
26  import java.util.Vector;
27  
28  /**
29   * No-operation implementation of Logger used by NOPLoggerRepository.
30   * @since 1.2.15
31   */
32  public final class NOPLogger extends Logger {
33      /**
34       * Create instance of Logger.
35       * @param repo repository, may not be null.
36       * @param name name, may not be null, use "root" for root logger.
37       */
38      public NOPLogger(NOPLoggerRepository repo, final String name) {
39          super(name);
40          this.repository = repo;
41          this.level = Level.OFF;
42          this.parent = this;
43      }
44  
45      /** {@inheritDoc} */
46      public void addAppender(final Appender newAppender) {
47      }
48  
49      /** {@inheritDoc} */
50      public void assertLog(final boolean assertion, final String msg) {
51      }
52  
53  
54      /** {@inheritDoc} */
55      public void callAppenders(final LoggingEvent event) {
56      }
57  
58      /** {@inheritDoc} */
59      void closeNestedAppenders() {
60      }
61  
62      /** {@inheritDoc} */
63      public void debug(final Object message) {
64      }
65  
66  
67      /** {@inheritDoc} */
68      public void debug(final Object message, final Throwable t) {
69      }
70  
71      /** {@inheritDoc} */
72      public void error(final Object message) {
73      }
74  
75      /** {@inheritDoc} */
76      public void error(final Object message, final Throwable t) {
77      }
78  
79  
80      /** {@inheritDoc} */
81      public void fatal(final Object message) {
82      }
83  
84      /** {@inheritDoc} */
85      public void fatal(final Object message, final Throwable t) {
86      }
87  
88  
89      /** {@inheritDoc} */
90      public Enumeration getAllAppenders() {
91        return new Vector().elements();
92      }
93  
94      /** {@inheritDoc} */
95      public Appender getAppender(final String name) {
96         return null;
97      }
98  
99      /** {@inheritDoc} */
100     public Level getEffectiveLevel() {
101       return Level.OFF;
102     }
103 
104     /** {@inheritDoc} */
105     public Priority getChainedPriority() {
106       return getEffectiveLevel();
107     }
108 
109     /** {@inheritDoc} */
110     public ResourceBundle getResourceBundle() {
111       return null;
112     }
113 
114 
115     /** {@inheritDoc} */
116     public void info(final Object message) {
117     }
118 
119     /** {@inheritDoc} */
120     public void info(final Object message, final Throwable t) {
121     }
122 
123     /** {@inheritDoc} */
124     public boolean isAttached(Appender appender) {
125       return false;
126     }
127 
128     /** {@inheritDoc} */
129     public boolean isDebugEnabled() {
130       return false;
131     }
132 
133     /** {@inheritDoc} */
134     public boolean isEnabledFor(final Priority level) {
135       return false;
136     }
137 
138     /** {@inheritDoc} */
139     public boolean isInfoEnabled() {
140       return false;
141     }
142 
143 
144     /** {@inheritDoc} */
145     public void l7dlog(final Priority priority, final String key, final Throwable t) {
146     }
147 
148     /** {@inheritDoc} */
149     public void l7dlog(final Priority priority, final String key,  final Object[] params, final Throwable t) {
150     }
151 
152     /** {@inheritDoc} */
153     public void log(final Priority priority, final Object message, final Throwable t) {
154     }
155 
156     /** {@inheritDoc} */
157     public void log(final Priority priority, final Object message) {
158     }
159 
160     /** {@inheritDoc} */
161     public void log(final String callerFQCN, final Priority level, final Object message, final Throwable t) {
162     }
163 
164     /** {@inheritDoc} */
165     public void removeAllAppenders() {
166     }
167 
168 
169     /** {@inheritDoc} */
170     public void removeAppender(Appender appender) {
171     }
172 
173     /** {@inheritDoc} */
174     public void removeAppender(final String name) {
175     }
176 
177     /** {@inheritDoc} */
178     public void setLevel(final Level level) {
179     }
180 
181 
182     /** {@inheritDoc} */
183     public void setPriority(final Priority priority) {
184     }
185 
186     /** {@inheritDoc} */
187     public void setResourceBundle(final ResourceBundle bundle) {
188     }
189 
190     /** {@inheritDoc} */
191     public void warn(final Object message) {
192     }
193 
194     /** {@inheritDoc} */
195     public void warn(final Object message, final Throwable t) {
196     }
197 
198     /** {@inheritDoc} */
199     public void trace(Object message) {
200     }
201 
202     /** {@inheritDoc} */
203     public void trace(Object message, Throwable t) {
204     }
205 
206     /** {@inheritDoc} */
207     public boolean isTraceEnabled() {
208         return false;
209     }
210 
211 
212 }