Repository: apache/dubbo
File: dubbo-common/src/main/java/org/apache/dubbo/common/logger/log4j2/Log4j2Logger.java (Java)

Code before:
package org.apache.dubbo.common.logger.log4j2;

import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.support.FailsafeLogger;

import org.apache.logging.log4j.Level;

public class Log4j2Logger implements Logger {

    private final String fqcn;

    private final org.apache.logging.log4j.spi.ExtendedLogger logger;

    public Log4j2Logger(org.apache.logging.log4j.spi.ExtendedLogger logger) {
        this.fqcn = FailsafeLogger.class.getName();
        this.logger = logger;
    }

    public Log4j2Logger(String fqcn, org.apache.logging.log4j.spi.ExtendedLogger logger) {
        this.fqcn = fqcn;
        this.logger = logger;
    }

    @Override
    public void trace(String msg) {
        logger.logIfEnabled(fqcn, Level.TRACE, null, logger.getMessageFactory().newMessage(msg), null);
    }

    @Override
    public void trace(String msg, Object... arguments) {
        logger.logIfEnabled(fqcn, Level.TRACE, null, logger.getMessageFactory().newMessage(msg, arguments), null);
    }

    @Override
    public void trace(Throwable e) {
        logger.logIfEnabled(
                fqcn, Level.TRACE, null, logger.getMessageFactory().newMessage(e == null ? null : e.getMessage()), e);
    }

    @Override
    public void trace(String msg, Throwable e) {
        logger.logIfEnabled(fqcn, Level.TRACE, null, logger.getMessageFactory().newMessage(msg), e);
    }

    @Override
    public void debug(String msg) {
        logger.logIfEnabled(fqcn, Level.DEBUG, null, logger.getMessageFactory().newMessage(msg), null);
    }

    @Override
    public void debug(String msg, Object... arguments) {

Review comment (suggestion):
Why not use `void logIfEnabled(String fqcn, Level level, Marker marker, String message)`

Code after:
package org.apache.dubbo.common.logger.log4j2;

import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.support.FailsafeLogger;

import org.apache.logging.log4j.Level;

public class Log4j2Logger implements Logger {

    private final String fqcn;

    private final org.apache.logging.log4j.spi.ExtendedLogger logger;

    public Log4j2Logger(org.apache.logging.log4j.spi.ExtendedLogger logger) {
        this.fqcn = FailsafeLogger.class.getName();
        this.logger = logger;
    }

    public Log4j2Logger(String fqcn, org.apache.logging.log4j.spi.ExtendedLogger logger) {
        this.fqcn = fqcn;
        this.logger = logger;
    }

    @Override
    public void trace(String msg) {
        logger.logIfEnabled(fqcn, Level.TRACE, null, msg);
    }

    @Override
    public void trace(String msg, Object... arguments) {
        logger.logIfEnabled(fqcn, Level.TRACE, null, msg, arguments);
    }

    @Override
    public void trace(Throwable e) {
        logger.logIfEnabled(fqcn, Level.TRACE, null, e == null ? null : e.getMessage(), e);
    }

    @Override
    public void trace(String msg, Throwable e) {
        logger.logIfEnabled(fqcn, Level.TRACE, null, msg, e);
    }

    @Override
    public void debug(String msg) {
        logger.logIfEnabled(fqcn, Level.DEBUG, null, msg);
    }

    @Override
    public void debug(String msg, Object... arguments) {
        logger.logIfEnabled(fqcn, Level.DEBUG, null, msg, arguments);