Spring配置文件无法正常运行

时间:2017-08-21 21:18:20

标签: java spring logback spring-profiles

我配置了logback, 但它总是使用我的本地资料, 即使我设置了-Dspring.profiles.active=dev。 有人解决了这个问题吗? 这是一段代码:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <include resource="org/springframework/boot/logging/logback/base.xml"/>
   <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
   <springProfile name="local">
      <include resource="logging/logback-local.xml"/>
   </springProfile>
   <springProfile name="dev">
      <!--Console Appender-->
      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
         <target>System.out</target>
         <encoder>
            <Pattern>
               %-5level [%thread] %class \(%file:%line\) - %m%n
            </Pattern>
         </encoder>
      </appender>
      <!--File Appender-->
      <include resource="logging/appenders/rolling-file-appender.xml"/>
      <!--Logger for springframework-->
      <logger name="org.springframework" level="debug" additivity="false">
         <appender-ref ref="STDOUT"/>
      </logger>
      <logger name="httpclient.wire" level="debug" additivity="false">
         <appender-ref ref="STDOUT"/>
      </logger>
      <!--Logger for all of Blah-->
      <logger name="com.blah" level="debug" additivity="false">
         <appender-ref ref="STDOUT"/>
      </logger>
      <!--Logger for test package-->
      <logger name="com.blah.test" level="debug" additivity="false">
         <appender-ref ref="FILE-APPENDER"/>
      </logger>
      <!--Root logger-->
      <root level="debug" additivity="false">
         <appender-ref ref="STDOUT" additivity="false"/>
      </root>
   </springProfile>

0 个答案:

没有答案