2016-07-13 6 views
0

Wildfly 10アプリケーションで、展開ごとのログを正常に動作させる上で問題があります。でも、メインのserver.logファイルで、Wildfly 10のデプロイメントごとのログ出力log4j.xmlがWARプロジェクトで無視される

<log4j:configuration debug="true" 
xmlns:log4j='http://jakarta.apache.org/log4j/'> 

<appender name="fileAppender" class="org.apache.log4j.rolling.RollingFileAppender"> 
    <param name="MaxFileSize" value="300MB" /> 
    <param name="append" value="true" /> 
    <param name="Encoding" value="UTF-8" /> 
    <param name="file" value="${jboss.server.log.dir}/rtc-notify.log" /> 

    <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"> 
     <!-- Archive file to roll to @ midnight (yyyy-MM-dd) with compression --> 
     <param name="FileNamePattern" 
      value="${jboss.server.log.dir}/rtc-notify.%d{yyyy-MM-dd}.log.gz" /> 
    </rollingPolicy> 

    <layout class="org.apache.log4j.PatternLayout"> 
     <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] [%t] %m%n" /> 
    </layout> 
</appender> 
<root> 
    <level value="DEBUG" /> 
    <appender-ref ref="fileAppender" /> 
</root> 
</log4j:configuration> 

しかし、ファイルが作成されることはありませんし、何のログはどこにも表示されません:

私はWEB-INF /クラスでlog4j.xmlファイルを置きます。

私はadd-logging-api-dependenciesuse-deployment-logging-configも変更していないので、これを受け入れるべきです。

多分pom.xmlの依存関係と関係がありますか?私は手動でBOMに依存しているここにすべての依存関係を変更し、すべきではない私は、JBoss-JavaEEの-7.0-と、ハイバネートBOMがWildfly 10のために用意されていないようするために8.2.0.Finalを使用してい

<?xml version="1.0" encoding="UTF-8"?> 
<!-- JBoss, Home of Professional Open Source Copyright 2013, Red Hat, Inc. 
    and/or its affiliates, and individual contributors by the @authors tag. See 
    the copyright.txt in the distribution for a full listing of individual contributors. 
    Licensed under the Apache License, Version 2.0 (the "License"); you may not 
    use this file except in compliance with the License. You may obtain a copy 
    of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
    by applicable law or agreed to in writing, software distributed under the 
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
    OF ANY KIND, either express or implied. See the License for the specific 
    language governing permissions and limitations under the License. --> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.myapp.notify</groupId> 
    <artifactId>myapp-notify</artifactId> 
    <version>1.0.0.Final</version> 
    <packaging>war</packaging> 
    <name>WildFly Quickstarts: myapp-notify</name> 
    <description>A starter Java EE 7 webapp project for use on JBoss WildFly/WildFly, generated from the jboss-javaee6-webapp archetype</description> 

    <url>http://wildfly.org</url> 
    <licenses> 
    <license> 
     <name>Apache License, Version 2.0</name> 
     <distribution>repo</distribution> 
     <url>http://www.apache.org/licenses/LICENSE-2.0.html</url> 
    </license> 
    </licenses> 

    <properties> 
    <!-- Explicitly declaring the source encoding eliminates the following 
     message: --> 
    <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
     resources, i.e. build is platform dependent! --> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 

    <!-- JBoss dependency versions --> 
    <version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin> 

    <!-- Define the version of the JBoss BOMs we want to import to specify 
     tested stacks. --> 
    <version.jboss.bom>8.2.0.Final</version.jboss.bom> 

    <!-- other plugin versions --> 
    <version.compiler.plugin>3.1</version.compiler.plugin> 
    <version.surefire.plugin>2.16</version.surefire.plugin> 
    <version.war.plugin>2.5</version.war.plugin> 

    <!-- maven-compiler-plugin --> 
    <maven.compiler.target>1.7</maven.compiler.target> 
    <maven.compiler.source>1.7</maven.compiler.source> 
    </properties> 


    <dependencyManagement> 
    <dependencies> 

     <dependency> 
     <groupId>org.wildfly</groupId> 
     <artifactId>wildfly-spec-api</artifactId> 
     <version>8.2.0.Final</version> 
     </dependency> 

     <dependency> 
     <groupId>org.wildfly.bom</groupId> 
     <artifactId>jboss-javaee-7.0-with-hibernate</artifactId> 
     <version>${version.jboss.bom}</version> 
     <type>pom</type> 
     <scope>import</scope> 
     <exclusions> 
      <exclusion> <!-- declare the exclusion here --> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-search</artifactId> 
      </exclusion> 
      <exclusion> <!-- declare the exclusion here --> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-search-analyzers</artifactId> 
      </exclusion> 
      <exclusion> <!-- declare the exclusion here --> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-search-engine</artifactId> 
      </exclusion> 
      <exclusion> <!-- declare the exclusion here --> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-search-orm</artifactId> 
      </exclusion> 
      <exclusion> <!-- declare the exclusion here --> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-search-infinispan</artifactId> 
      </exclusion> 
     </exclusions> 
     </dependency> 

     <!-- https://mvnrepository.com/artifact/log4j/log4j --> 
     <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.17</version> 
     <scope>provided</scope> 
     </dependency> 


     <!-- <dependency> --> 
     <!-- <groupId>org.slf4j</groupId> --> 
     <!-- <artifactId>slf4j-log4j12</artifactId> --> 
     <!-- <version>1.7.10</version> --> 
     <!-- </dependency> --> 

     <!-- <dependency> --> 
     <!-- <groupId>org.slf4j</groupId> --> 
     <!-- <artifactId>slf4j-api</artifactId> --> 
     <!-- <version>1.7.10</version> --> 
     <!-- </dependency> --> 

     <!-- <dependency> --> 
     <!-- <groupId>org.slf4j</groupId> --> 
     <!-- <artifactId>slf4j-simple</artifactId> --> 
     <!-- <version>1.7.10</version> --> 
     <!-- </dependency> --> 

    </dependencies> 
    </dependencyManagement> 

    <dependencies> 

    <dependency> 
     <groupId>org.hibernate.javax.persistence</groupId> 
     <artifactId>hibernate-jpa-2.1-api</artifactId> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-search-backend-jms</artifactId> 
     <version>5.2.0.Final</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-search-orm</artifactId> 
     <version>5.2.0.Final</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-search-engine</artifactId> 
     <version>5.2.0.Final</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-search-infinispan</artifactId> 
     <version>5.2.0.Final</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.infinispan</groupId> 
     <artifactId>infinispan-core</artifactId> 
     <version>7.0.3.Final</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-entitymanager</artifactId> 
     <scope>provided</scope> 
    </dependency> 


    <dependency> 
     <groupId>org.jboss.spec.javax.jms</groupId> 
     <artifactId>jboss-jms-api_2.0_spec</artifactId> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-core-asl</artifactId> 
     <version>1.9.13</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.spec.javax.json</groupId> 
     <artifactId>jboss-json-api_1.0_spec</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.tomcat</groupId> 
     <artifactId>tomcat-catalina</artifactId> 
     <version>8.0.12</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.spec.javax.websocket</groupId> 
     <artifactId>jboss-websocket-api_1.0_spec</artifactId> 
     <scope>provided</scope> 
    </dependency> 

    <!-- First declare the APIs we depend on and need for compilation. All 
     of them are provided by JBoss WildFly --> 

    <!-- Import the CDI API, we use provided scope as the API is included in 
     JBoss WildFly --> 
    <dependency> 
     <groupId>javax.enterprise</groupId> 
     <artifactId>cdi-api</artifactId> 
     <scope>provided</scope> 
    </dependency> 

    <!-- Import the Common Annotations API (JSR-250), we use provided scope 
     as the API is included in JBoss WildFly --> 
    <dependency> 
     <groupId>org.jboss.spec.javax.annotation</groupId> 
     <artifactId>jboss-annotations-api_1.2_spec</artifactId> 
     <scope>provided</scope> 
    </dependency> 

    <!-- Import the JAX-RS API, we use provided scope as the API is included 
     in JBoss WildFly --> 
    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>jaxrs-api</artifactId> 
     <scope>provided</scope> 
    </dependency> 

    <!-- Import the EJB API, we use provided scope as the API is included in 
     JBoss WildFly --> 
    <dependency> 
     <groupId>org.jboss.spec.javax.ejb</groupId> 
     <artifactId>jboss-ejb-api_3.2_spec</artifactId> 
     <scope>provided</scope> 
    </dependency> 

    </dependencies> 

    <build> 
    <!-- Maven will append the version to the finalName (which is the name 
     given to the generated war, and hence the context root) --> 
    <finalName>${project.artifactId}</finalName> 
    <plugins> 
     <plugin> 
     <artifactId>maven-war-plugin</artifactId> 
     <version>${version.war.plugin}</version> 
     <configuration> 
      <!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! --> 
      <failOnMissingWebXml>false</failOnMissingWebXml> 
     </configuration> 
     </plugin> 
     <!-- The WildFly plugin deploys your war to a local WildFly container --> 
     <!-- To use, run: mvn package wildfly:deploy --> 
     <plugin> 
     <groupId>org.wildfly.plugins</groupId> 
     <artifactId>wildfly-maven-plugin</artifactId> 
     <version>${version.wildfly.maven.plugin}</version> 
     <configuration> 
      <filename>${project.artifactId}.war</filename> 
      <skip>false</skip> 
      <home>${wildfly-home}</home> 
      <hostname>${wildfly-hostname}</hostname> 
      <port>${wildfly-port}</port> 
      <username>${wildfly-username}</username> 
      <password>${wildfly-password}</password> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 

</project> 

答えて

0

問題は、使用しようとしていたFileAppenderにありました。毎日圧縮されたRollingFileAppenderは、基本的なlog4jパッケージでは使用できません。 apache-log4j-extrasパッケージは必要ですが、Wildfly 10は付属していません。Wildfly 8の以前の設定では、このモジュールを手動で追加しましたが、移行中に忘れてしまっていました。

+0

これはlog4jで利用できますが、 'org.apache.log4j.rolling'パッケージには含まれていません。これは 'org.apache.log4j.RollingFileAppender'を使用すると動作します。 FWIW私はlog4jからエラーメッセージを出力しないというエラーを修正するためにJIRAを提出しました。https://issues.jboss.org/browse/WFCORE-1656 –

+0

私はそれを認識しませんでした。基本的なlog4jライブラリについてのヒントをありがとう。余分なモジュールを使用することを避ければよい。そして、はい、エラーメッセージのいくつかの種類は非常に便利です。 – PawelPredki

+0

しかし、私がドキュメントで見る限り、TimeBasedRollingPolicyクラスは基本的なlog4jパッケージでは使用できません。DailyRollingFileAppenderにはいくつかの問題があると言われているので、とにかくエクストラの使用が推奨されています。そのような場合は、既に設定済みで機能しているように、エクストラを使用することに固執すると思います。 – PawelPredki

関連する問題