覆盖WildFly中的日志记录 [英] Override logging in WildFly
问题描述
我使用了tomcat,并简单地覆盖了默认的日志记录系统.如何在我的Spring应用程序中启用对Wildfly的日志记录登录?
I used tomcat and simply override default logging system. How to enable logging with logback on wildfly in my spring app?
我在tomcat上拥有的Logback.xml
My Logback.xml owrking on tomcat
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
</encoder>
</appender>
<logger name="org.springframework" level="WARN" />
<logger name="com.citronium.planstery" level="INFO" />
<logger name="org.apache.http.impl.conn.tsccm" level="ERROR" />
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
推荐答案
您可以使用logback在应用程序中配置日志记录.您不能使用logback来配置服务器的日志记录.
You can use logback to configure logging in your application. You can't use logback to configure logging for the server.
要在配置中使用logback,您需要将add-logging-api-dependencies
更改为false
或创建一个不包含子系统的jboss-deployment-structure.xml
.您还需要在部署中包括logback和slf4j.
To use logback in your configuration you'll need to change the add-logging-api-dependencies
to false
or create a jboss-deployment-structure.xml
that excludes the subsystem. You'll also need to include logback and slf4j in your deployment.
更改add-logging-api-dependencies
的第一个选项是所有部署的全局设置.以下CLI命令将更改值:
The first option of changing the add-logging-api-dependencies
is a global setting for all deployments. The follow CLI command will change the value:
/subsystem=logging:write-attribute(name=add-logging-api-dependencies,value=false)
此选项根本不会添加任何隐式将依赖项记录到您的部署中.
This option simply doesn't add any of the implicit logging dependencies to your deployment.
使用jboss-deployment-structure.xml
的第二个选项将仅为您的部署禁用日志记录子系统.以下是示例文件:
The second option of using a jboss-deployment-structure.xml
will disable the logging subsystem for your deployment only. The following is an example file:
<jboss-deployment-structure>
<deployment>
<!-- exclude-subsystem prevents a subsystems deployment unit processors running on a deployment -->
<!-- which gives basically the same effect as removing the subsystem, but it only affects single deployment -->
<exclude-subsystems>
<subsystem name="logging" />
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
这篇关于覆盖WildFly中的日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!