springboot中logback-spring.xml中日志输出到rabbitmq

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" debug="false">
    <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
           <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
              <pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="AMQP" class="org.springframework.amqp.rabbit.logback.AmqpAppender">
        <layout>
            <pattern><![CDATA[ %d %p %t [%c] - <%m>%n ]]></pattern>
        </layout>
        <addresses>192.168.1.100:5672</addresses>
        <username>admin</username>
        <password>admin</password>
        <virtualHost>/</virtualHost>
        <param name="virtualHost" value="/" />
        <abbreviation>36</abbreviation>
        <includeCallerData>false</includeCallerData>
        <applicationId>dataquality</applicationId>
        <routingKeyPattern>logstash</routingKeyPattern>
        <generateId>true</generateId>
        <charset>UTF-8</charset>
        <durable>true</durable>
        <deliveryMode>NON_PERSISTENT</deliveryMode>
        <declareExchange>true</declareExchange>
        <exchangeName>rabbit.logs</exchangeName>
        <exchangeType>queue</exchangeType>
    </appender>

    <logger name="ch.qos.logback" level="DEBUG"/>
    <logger name="org.apache" level="WARN"/>
    <logger name="org.hibernate" level="DEBUG"/>
    <logger name="org.springframework" level="INFO"/>
    <logger name="de.ksbrwsk" level="INFO"/>

    <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
        <resetJUL>true</resetJUL>
    </contextListener>
    
<!--     <root level="info"> #logback.loglevel#-->
<!--         <appender-ref ref="STDOUT"/> -->
<!--         <appender-ref ref="CONSOLE"/> -->
<!--         <appender-ref ref="AMQP"/> -->
<!--     </root> -->

    <root level="DEBUG">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="AMQP"/>
    </root>
</configuration>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值