logback日志配置获取服务器名称/ip/pid/端口

1、获取服务器名称/ip/pid/端口方法详见:https://www.jianshu.com/p/346f9f50ac88

2、创建一个类继承自ch.qos.logback.classic.pattern.ClassicConverter,重写方法:

@Override

 public String convert(ILoggingEvent event) {}

3、在logback-spring.xml文件里加入配置获取ip类

4、具体使用:

"host": "%ip" 这样写,本地日志输入的时候内容是: "host": "127.0.0.1"

具体详见:https://blog.csdn.net/ming451294498/article/details/90205195?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522159772171519724839250350%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=159772171519724839250350&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-1-90205195.first_rank_ecpm_v3_pc_rank_v2&utm_term=logback+%E6%89%93%E5%8D%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%BF%A1%E6%81%AF&spm=1018.2118.3001.4187

你可能感兴趣的:(logback日志配置获取服务器名称/ip/pid/端口)