2017-09-11 10 views

答えて

0

Logbackは、特定の順序で構成ファイルを検索します(the docs hereを参照)。最初に、クラスパスにlogback-test.xmlというファイルがあります。 mavenを使用しているので、のテスト/リソースディレクトリにそのファイルを含めてください。こうすることで、テストを実行しているときにlogback-test.xmlファイルが使用されます。プロダクションコードの場合は、メイン/リソースディレクトリにlogback.xmlを含めます。

0

私は、次のMavenの設定を思い付いた:Mavenの設定ファイルで

<profile> 
     <id>development</id> 
     <activation> 
      <property> 
       <name>dev</name> 
      </property> 
     </activation> 
     <build> 
      <resources> 
       <resource> 
        <filtering>true</filtering><!-- if it is neccessary --> 
        <directory>src/main/logging/develop</directory><!-- from --> 
        <targetPath>${project.build.outputDirectory}</targetPath><!-- to --> 
        <includes><!-- what --> 
         <include>logback.xml</include> 
        </includes> 
       </resource> 
       <resource> 
        <directory>src/main/resources</directory> 
        <includes> 
         <include>**/*</include> 
        </includes> 
       </resource> 
      </resources> 
     </build> 
    </profile> 
</profiles> 

、我々はデフォルトごとにプロファイルを有効にすることができます。

<settings> 
    [..] 
    <activeProfiles> 
    <activeProfile>development</activeProfile> 
    </activeProfiles> 
    [..] 
</settings> 

もう一つの方法は、にデフォルトのプロファイル設定を移動することです「通常の」pom構築セクション。

開発プロファイルを有効にするには、コマンドラインからdebugフラグを渡します。 mvn package -Ddev

関連する問題