Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java WAR项目忽略每个部署日志log4j.xml的Wildfly 10_Java_Maven_Logging_Wildfly_Wildfly 10 - Fatal编程技术网

Java WAR项目忽略每个部署日志log4j.xml的Wildfly 10

Java WAR项目忽略每个部署日志log4j.xml的Wildfly 10,java,maven,logging,wildfly,wildfly-10,Java,Maven,Logging,Wildfly,Wildfly 10,我在让我的Wildfly 10应用程序中的每次部署日志正常工作时遇到问题 我将log4j.xml文件放在WEB-INF/classes中: <log4j:configuration debug="true" xmlns:log4j='http://jakarta.apache.org/log4j/'> <appender name="fileAppender" class="org.apache.log4j.rolling.RollingFileAppender">

我在让我的Wildfly 10应用程序中的每次部署日志正常工作时遇到问题

我将log4j.xml文件放在WEB-INF/classes中:

<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>

我在jboss-javaee-7.0-with-hibernate中使用8.2.0.Final,因为没有为Wildfly 10准备BOM。我是否应该在此处手动更改所有依赖项而不依赖bom表?

问题在于我尝试使用的FileAppender。基本log4j包中没有具有每日压缩功能的RollingFileAppender。apache-log4j-extras包是必需的,但它没有随Wildfly 10提供。在之前的Wildfly 8安装中,我们手动添加了此模块,但在迁移过程中被遗忘。

问题在于我尝试使用的FileAppender。基本log4j包中没有具有每日压缩功能的RollingFileAppender。apache-log4j-extras包是必需的,但它没有随Wildfly 10提供。在之前的Wildfly 8安装中,我们手动添加了此模块,但在迁移过程中它被遗忘了。

它在log4j中可用,只是不在
org.apache.log4j.rolling
包中。如果您使用
org.apache.log4j.RollingFileAppender
,它就会工作。FWIW我已经提交了一份JIRA来修复没有打印来自log4j的错误消息的错误,我对此一无所知。感谢您提供有关基本log4j库的提示。最好不要使用额外的模块。是的,某些类型的错误消息将非常有用。但是,据我在文档中看到的,TimeBasedRollingPolicy类在基本log4j包中不可用,DailyRollingFileAppender据说有一些问题,因此无论如何都建议使用额外的。在这种情况下,我认为我们将坚持使用extras,因为它已经配置好并正在工作。FWIW在基本log4j库中有一个。“观察到DailRollingFileAppender出现同步问题和数据丢失。log4j extras companion包括新部署应考虑的备选方案,这些方案在org.apache.log4j.rolling.RollingFileAppender的文档中进行了讨论。“从中,它可以在log4j中获得,只是不在
org.apache.log4j.rolling
包中。如果您使用
org.apache.log4j.RollingFileAppender
,它就会工作。FWIW我已经提交了一份JIRA来修复没有打印来自log4j的错误消息的错误,我对此一无所知。感谢您提供有关基本log4j库的提示。最好不要使用额外的模块。是的,某些类型的错误消息将非常有用。但是,据我在文档中看到的,TimeBasedRollingPolicy类在基本log4j包中不可用,DailyRollingFileAppender据说有一些问题,因此无论如何都建议使用额外的。在这种情况下,我认为我们将坚持使用extras,因为它已经配置好并正在工作。FWIW在基本log4j库中有一个。“观察到DailRollingFileAppender出现同步问题和数据丢失。log4j extras companion包括新部署应考虑的备选方案,这些方案在org.apache.log4j.rolling.RollingFileAppender的文档中进行了讨论
<?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>