package com.lutao.cloud.admin.logback;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Create by guoyc on 2021/12/21
 */
@Configuration
public class FilterConfiguration{
    @Bean
    public FilterRegistrationBean logFilterRegistration(){
        FilterRegistrationBean registration = new FilterRegistrationBean();
        //注入过滤器
        registration.setFilter(new LogMDCFilter());
        //拦截规则
        registration.addUrlPatterns("/*");
        //过滤器名称
        registration.setName("logMDCFilter");
        //过滤器顺序
        registration.setOrder(0);
        return registration;
    }
}
