美文网首页程序员互联网科技
编写可移植性更强的程序:spring boot工程在applic

编写可移植性更强的程序:spring boot工程在applic

作者: 大神带我来搬砖 | 来源:发表于2018-03-29 16:51 被阅读223次

    在spring boot工程中,为了灵活切换部署环境,可以把application.properties文件放到jar包外部.
    如果使用了log4j2作为日志框架,想在不同的部署环境上灵活log4j2的日志输出目录,可以用以下方法
    1 在application.properties中设置logging.config来设定log4j2配置文件的位置
    2 在application.properties中设置logging.path,在resources目录下放置log4j2-spring.xml来作为log4j2的配置文件,在log4j2-spring.xml中使用${sys:LOG_PATH}作为日志输出路径

    对于logback等日志框架,也可以使用同样的方法
    原文见https://docs.spring.io/spring-boot/docs/1.5.7.RELEASE/reference/htmlsingle/#boot-features-custom-log-configuration

    相关文章

      网友评论

        本文标题:编写可移植性更强的程序:spring boot工程在applic

        本文链接:https://www.haomeiwen.com/subject/nzuucftx.html