当我在Wildfly10上部署war时,Log4j日志不会打印。1.0.最终的不过,它与Tomcat配合得很好。
我在网上发现Wildfly使用log4j,所以我在jboss部署结构中排除了log4j。下面的xml避免了依赖冲突,但没有运气。
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<!-- for top deployment, e.g. ear -->
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.slf4j" />
<module name='org.slf4j.impl' />
<module name="org.apache.log4j" />
<module name="com.microsoft.sqlserver.jdbc" />
<module name="peslib" />
</exclusions>
</deployment>
<!-- for sub deployment, e.g. war. sub-deployment is required when ear contains one or more wars -->
</jboss-deployment-structure>
下面是我log4.properties档案
log4j.rootLogger=ERROR,file,Stdout
log4j.logger.com.persivia.ptf=INFO
log4j.appender.Stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{ISO8601}] [%p] %c{1}:%L - %m%n
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:/Logs/ptf-patient-service.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%d{ISO8601}] [%p] %c{1}:%L - %m%n
下面是我的pom。xml依赖关系
<dependencies>
<!-- Spring core & mvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.5.RELEASE</version>
</dependency>
<!-- Servlet Spec -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.2.1</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4jVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4jVersion}</version>
<type>pom</type>
</dependency>
<!-- Swagger UI dependency -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
<!-- portal imports end -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<!-- Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- Mockito -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.28.2</version>
<scope>test</scope>
</dependency>
</dependencies>
下面是我部署战争时得到的错误日志。
19:04:01,579 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR A "org.apache.log4j.RollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
19:04:01,579 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
19:04:01,581 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR [ModuleClassLoader for Module "deployment.ptf-patient-service.war:main" from Service Module Loader] whereas object of type
19:04:01,584 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR "org.apache.log4j.RollingFileAppender" was loaded by [ModuleClassLoader for Module "org.jboss.log4j.logmanager:main" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: C:\wildfly\modules,C:\wildfly\modules\system\layers\base))].
19:04:01,585 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR Could not instantiate appender named "file".
19:04:01,586 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
19:04:01,586 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
19:04:01,587 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR [ModuleClassLoader for Module "deployment.ptf-patient-service.war:main" from Service Module Loader] whereas object of type
19:04:01,587 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [ModuleClassLoader for Module "org.jboss.log4j.logmanager:main" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: C:\wildfly\modules,C:\wildfly\modules\system\layers\base))].
19:04:01,588 ERROR [stderr] (MSC service thread 1-6) log4j:ERROR Could not instantiate appender named "Stdout".
我正在尝试运行独立的完整ha。xml
尝试从排除列表中删除以下行:
<module name="org.slf4j" />
<module name='org.slf4j.impl' />
根据spring boot文档(最新版本),它提到spring boot在内部使用logback。 我使用了log4j启动器,如下所述,不包括logback 例如,如果下面的命令在调试模式下运行(假设sboot1是我的uber jar) 我没有得到调试日志,这些日志是之前使用logback生成的,logback显示了“排除”和“包含”以及其他必要的信息。 当使用其他日志框架(如log4j)时,如何
环境:Java、Selenium webdriver、Maven、testNG、Log4J、Eclipse XML 我添加了log4j。src/main/resources下的属性。 在基本测试中。java,我在导入log4j后添加了两行。 日志信息(“方法设置”); 日志信息(“方法拆除”); 我的目标是能够使用日志。了解整个项目。在此之前,我只想通过在basetest类中导入log4j log
我正试图从迁移到,但在所有更改之后,日志没有打印出来。我使用的“选项2”是https://logging.apache.org/log4j/2.x/manual/migration.html . 我添加了在我的libs文件夹中,并正确配置了在
我试图实现log4j。我用log4j创建了一个示例java程序。 下面是我的log4j。属性: 我正在控制台屏幕上获取输出。但是没有生成日志文件。我必须做什么才能生成日志文件,谢谢
我知道有很多关于这个的问题,但是我确实经历了所有的问题,并且有点困惑自己,我列出了我遵循的步骤,请让我知道我把它搞砸了。 1) 我只想在应用程序级别使用Log4j,所以需要复制WL_HOME/server/lib/wllog4j。jar和log4j。jar在Domail_Home/Lib? 2) 我使用的是Maven,我在pom中添加了Log4j依赖项。xml[war]。我把战争藏在耳朵里。 3)
问题内容: 我的应用程序有一个自制的日志记录类,我将在后台使用log4j进行迁移。但是,由于我正在使用homebrew类将应用程序的其余日志记录语句传递给log4j,因此输出语句被记录为来自包装类而不是源类。 除了为每个log语句创建新的org.apache.log4j.Logger实例之外,是否有办法确保显示“正确的”源?我也尝试过使用Logger.log(String callerFQCN,P