Log4jImpl.java

  1. /*
  2.  *    Copyright 2009-2021 the original author or authors.
  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.apache.ibatis.logging.log4j;

  17. import org.apache.ibatis.logging.Log;
  18. import org.apache.log4j.Level;
  19. import org.apache.log4j.Logger;

  20. /**
  21.  * @author Eduardo Macarron
  22.  * @deprecated Since 3.5.9 - See https://github.com/mybatis/mybatis-3/issues/1223. This class will remove future.
  23.  */
  24. @Deprecated
  25. public class Log4jImpl implements Log {

  26.   private static final String FQCN = Log4jImpl.class.getName();

  27.   private final Logger log;

  28.   public Log4jImpl(String clazz) {
  29.     log = Logger.getLogger(clazz);
  30.   }

  31.   @Override
  32.   public boolean isDebugEnabled() {
  33.     return log.isDebugEnabled();
  34.   }

  35.   @Override
  36.   public boolean isTraceEnabled() {
  37.     return log.isTraceEnabled();
  38.   }

  39.   @Override
  40.   public void error(String s, Throwable e) {
  41.     log.log(FQCN, Level.ERROR, s, e);
  42.   }

  43.   @Override
  44.   public void error(String s) {
  45.     log.log(FQCN, Level.ERROR, s, null);
  46.   }

  47.   @Override
  48.   public void debug(String s) {
  49.     log.log(FQCN, Level.DEBUG, s, null);
  50.   }

  51.   @Override
  52.   public void trace(String s) {
  53.     log.log(FQCN, Level.TRACE, s, null);
  54.   }

  55.   @Override
  56.   public void warn(String s) {
  57.     log.log(FQCN, Level.WARN, s, null);
  58.   }

  59. }