Spring 学习日志框架

1、Spring开启Debug模式

yml 配置文件中配置

debug:true

2、@Conditional

@Configuration 中配置 @Conditional 可以实现根据条件选择性的将 Bean 添加到 Spring 容器中

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Conditional {

   /**
    * All {@link Condition Conditions} that must {@linkplain Condition#matches match}
    * in order for the component to be registered.
    */
   Class<? extends Condition>[] value();

}

@Conditional 条件必须继承 Condition.java,实现 {@link Condition#matches} 接口用来确定条件是否满足

@FunctionalInterface
public interface Condition {

   /**
    * Determine if the condition matches.
    * @param context the condition context
    * @param metadata metadata of the {@link org.springframework.core.type.AnnotationMetadata class}
    * or {@link org.springframework.core.type.MethodMetadata method} being checked
    * @return {@code true} if the condition matches and the component can be registered,
    * or {@code false} to veto the annotated component's registration
    */
   boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata);

}

3、日志框架

  • 日志原理
日志门面日志实现
JCL、SLF4J、jboss-loggingLog4j、JUL、Log4J2、Logback

slf4j:是 Log 抽象框架
Log4J、JUL、Log4J、Logback:是 Log 实现框架

Log4J:是最早的log框架,但对 slf4j 兼容不是很好
Log4J2:是 Apache 公司开发的
Logback :是与 slf4j 同一个作者开发的
在这里插入图片描述

  • Spring 适配其他 Log 框架原理:
    替换其他日志的方式是使用相同包名、类名的java类去替代原生的java log库

4、IDEA 可以在 pom.xml 右击Digrams -> Show Dependencies 来显示

5、Spring 排除库的标准方式

<exclusions>
    <exclusion>
        <groupId>com.xxx.xxx</groupId>
        <artifactId>xxx</artifactId>
    </exclusion>
</exclusions>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值