Logger Adapter Extension

Logger Adapter Extension

Extension Description

Log output adaptation extension point.

Extension Interface

org.apache.dubbo.common.logger.LoggerAdapter

Extension Configuration

  1. <dubbo:application logger="xxx" />

or:

  1. -Ddubbo:application.logger=xxx

Known Extensions

  • 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

Extension Example

Maven project structure:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxLoggerAdapter.java (implements LoggerAdapter interface)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-org.apache.dubbo.common.logger.LoggerAdapter (plain text file, content: xxx=com.xxx.XxxLoggerAdapter)

XxxLoggerAdapter.java:

  1. package com.xxx;
  2. import org.apache.dubbo.common.logger.LoggerAdapter;
  3. public class XxxLoggerAdapter implements LoggerAdapter {
  4. public Logger getLogger(URL url) {
  5. // ...
  6. }
  7. }

XxxLogger.java:

  1. package com.xxx;
  2. import org.apache.dubbo.common.logger.Logger;
  3. public class XxxLogger implements Logger {
  4. public XxxLogger(URL url) {
  5. // ...
  6. }
  7. public void info(String msg) {
  8. // ...
  9. }
  10. // ...
  11. }

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

  1. xxx=com.xxx.XxxLoggerAdapter

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)