日志适配扩展

扩展说明

日志输出适配扩展点。

扩展端口

org.apache.dubbo.common.logger.LoggerAdapter

扩展配置

<dubbo:application logger="xxx" />

-Ddubbo:application.logger=xxx

已知扩展

  • org.apache.dubbo.common.logger.slf4j.Slf4jLoggerAdapter
  • org.apache.dubbo.common.logger.jcl.JclLoggerAdapter
  • org.apache.dubbo.common.logger.log4j.Log4jLoggerAdapter
  • org.apache.dubbo.common.logger.log4j2.Log4j2LoggerAdapter
  • org.apache.dubbo.common.logger.jdk.JdkLoggerAdapter

扩展示例

Maven 项目结构

src
 |-main
    |-java
        |-com
            |-xxx
                |-XxxLoggerAdapter.java (implement LoggerAdapter interface)
    |-resources
        |-META-INF
            |-dubbo
                |-org.apache.dubbo.common.logger.LoggerAdapter (plain text file, content: xxx=com.xxx.XxxLoggerAdapter)

XxxLoggerAdapter.java

package com.xxx;
 
import org.apache.dubbo.common.logger.LoggerAdapter;
 
public class XxxLoggerAdapter implements LoggerAdapter {
    public Logger getLogger(URL url) {
        //...
    }
}

XxxLogger.java

package com.xxx;
 
import org.apache.dubbo.common.logger.Logger;
 
public class XxxLogger implements Logger {
    public XxxLogger(URL url) {
        //...
    }
    public void info(String msg) {
        //...
    }
    //...
}

META-INF/dubbo/org.apache.dubbo.common.logger.LoggerAdapter

xxx=com.xxx.XxxLoggerAdapter

上次修改时间 2023 年 1 月 2 日: 增强英文文档 (#1798) (95a9f4f6c1c)