Log4j2LoggerImpl.java

  1. /*
  2.  *    Copyright 2009-2022 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.log4j2;

  17. import org.apache.ibatis.logging.Log;
  18. import org.apache.ibatis.logging.LogFactory;
  19. import org.apache.logging.log4j.Logger;
  20. import org.apache.logging.log4j.Marker;
  21. import org.apache.logging.log4j.MarkerManager;

  22. /**
  23.  * @author Eduardo Macarron
  24.  */
  25. public class Log4j2LoggerImpl implements Log {

  26.   private static final Marker MARKER = MarkerManager.getMarker(LogFactory.MARKER);

  27.   private final Logger log;

  28.   public Log4j2LoggerImpl(Logger logger) {
  29.     log = logger;
  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.error(MARKER, s, e);
  42.   }

  43.   @Override
  44.   public void error(String s) {
  45.     log.error(MARKER, s);
  46.   }

  47.   @Override
  48.   public void debug(String s) {
  49.     log.debug(MARKER, s);
  50.   }

  51.   @Override
  52.   public void trace(String s) {
  53.     log.trace(MARKER, s);
  54.   }

  55.   @Override
  56.   public void warn(String s) {
  57.     log.warn(MARKER, s);
  58.   }

  59. }