Log4jImpl.java

  1. /*
  2.  *    Copyright 2009-2023 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.  *       https://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.  *
  23.  * @deprecated Since 3.5.9 - See https://github.com/mybatis/mybatis-3/issues/1223. This class will remove future.
  24.  */
  25. @Deprecated
  26. public class Log4jImpl implements Log {

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

  28.   private final Logger log;

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

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

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

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

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

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

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

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

  60. }