覆盖 WildFly 中的日志记录 [英] Override logging in WildFly
问题描述
我使用了 tomcat 并简单地覆盖了默认的日志系统.如何在我的 Spring 应用程序中使用 Wildfly 上的 logback 启用日志记录?
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屋!