Wildfly 10没有将日志写入周期性处理程序

时间:2017-05-08 11:32:03

标签: java logging jboss log4j wildfly

我的战争myApp已部署到wildfly 10中。

myApp有自己的log4j.properties:

log4j.rootLogger=DEBUG, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d - myApp: %m %n

Wildfly具有默认的独立配置

Root Logger

  • 处理程序:CONSOLE FILE
  • 等级:INFO

Handler CONSOLE

  • 等级:INFO
  • 模式:%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n
  • 目标:System.out

处理程序文件(定期)

  • 等级:ALL
  • 模式:%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n

在Wildfly控制台中,我可以看到myApp生成的日志:

12:58:43,480 INFO  [io.undertow.servlet] (ServerService Thread Pool -- 65) 2 Spring WebApplicationInitializers detected on classpath
12:58:43,521 INFO  [io.undertow.servlet] (ServerService Thread Pool -- 63) 2 Spring WebApplicationInitializers detected on classpath
2017-05-08 12:58:44,337 - myApp:  
2017-05-08 12:58:44,353 - myApp:   .   ____          _            __ _ _ 
2017-05-08 12:58:44,353 - myApp:  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \ 
2017-05-08 12:58:44,353 - myApp: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 
2017-05-08 12:58:44,354 - myApp:  \\/  ___)| |_)| | | | | || (_| |  ) ) ) ) 
2017-05-08 12:58:44,354 - myApp:   '  |____| .__|_| |_|_| |_\__, | / / / / 
2017-05-08 12:58:44,354 - myApp:  =========|_|==============|___/=/_/_/_/ 
2017-05-08 12:58:44,360 - myApp:  :: Spring Boot ::        (v1.4.1.RELEASE) 
2017-05-08 12:58:44,361 - myApp:  
12:58:44,366 INFO  [stdout] (ServerService Thread Pool -- 65) 
12:58:44,366 INFO  [stdout] (ServerService Thread Pool -- 65)   .   ____          _            __ _ _
12:58:44,366 INFO  [stdout] (ServerService Thread Pool -- 65)  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
12:58:44,366 INFO  [stdout] (ServerService Thread Pool -- 65) ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
12:58:44,367 INFO  [stdout] (ServerService Thread Pool -- 65)  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
12:58:44,367 INFO  [stdout] (ServerService Thread Pool -- 65)   '  |____| .__|_| |_|_| |_\__, | / / / /
12:58:44,367 INFO  [stdout] (ServerService Thread Pool -- 65)  =========|_|==============|___/=/_/_/_/
12:58:44,375 INFO  [stdout] (ServerService Thread Pool -- 65)  :: Spring Boot ::        (v1.4.3.RELEASE)
12:58:44,375 INFO  [stdout] (ServerService Thread Pool -- 65) 

但是我无法在server.log中找到它们:

12:58:43,480 INFO  [io.undertow.servlet] (ServerService Thread Pool -- 65) 2 Spring WebApplicationInitializers detected on classpath
12:58:43,521 INFO  [io.undertow.servlet] (ServerService Thread Pool -- 63) 2 Spring WebApplicationInitializers detected on classpath
12:58:44,366 INFO  [stdout] (ServerService Thread Pool -- 65) 
12:58:44,366 INFO  [stdout] (ServerService Thread Pool -- 65)   .   ____          _            __ _ _
12:58:44,366 INFO  [stdout] (ServerService Thread Pool -- 65)  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
12:58:44,366 INFO  [stdout] (ServerService Thread Pool -- 65) ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
12:58:44,367 INFO  [stdout] (ServerService Thread Pool -- 65)  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
12:58:44,367 INFO  [stdout] (ServerService Thread Pool -- 65)   '  |____| .__|_| |_|_| |_\__, | / / / /
12:58:44,367 INFO  [stdout] (ServerService Thread Pool -- 65)  =========|_|==============|___/=/_/_/_/
12:58:44,375 INFO  [stdout] (ServerService Thread Pool -- 65)  :: Spring Boot ::        (v1.4.3.RELEASE)
12:58:44,375 INFO  [stdout] (ServerService Thread Pool -- 65) 

为什么?

1 个答案:

答案 0 :(得分:0)

您的日志记录由应用中配置的ConsoleAppender处理,而不是服务器日志配置。我们对应用程序也存在同样的问题,该应用程序也有自己的日志记录配置。由于它是服务器上唯一的应用程序,因此我们强制应用程序使用(扩展为我们的应用程序)服务器日志记录配置。在独立* .xml文件中,在xmlns =" urn:jboss:domain:logging:3.0"顶部添加。节:

<use-deployment-logging-config value="false"/>