如何将信息日志和错误日志记录到 WILD FLY 服务器中的不同文件中? [英] how to log info logs and error logs into different files in WILD FLY server?

查看:34
本文介绍了如何将信息日志和错误日志记录到 WILD FLY 服务器中的不同文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 standalone.xml 文件中做了如下更改:

I have made changed in the standalone.xml file as below :

 <periodic-rotating-file-handler name="MYLOG" autoflush="true" enabled="true">
    <level name="ERROR"/>
    <formatter>
        <named-formatter name="json"/>
    </formatter>
    <file relative-to="jboss.server.log.dir" path="my_error.log"/>
    <suffix value=".yyyy-MM-dd"/>
    <append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.abc.api" use-parent-handlers="false">
    <level name="ERROR"/>
    <handlers>
      <handler name="MYLOG"/>
    </handlers>
</logger>

但是这个处理程序在 my_error.log 中为 com.abc.api 包打印 ERROR 日志.我还想在 my_info.log 文件中打印 com.abc.api 包的 INFO 日志.

But this handler print ERROR logs in my_error.log for com.abc.api package.I also wanted to print the INFO logs of com.abc.api package in my_info.log file.

有人可以帮忙吗.

推荐答案

您可以在处理程序上使用 levels 过滤器来过滤您希望在处理程序中看到的日志消息.您可以使用以下 CLI 命令配置日志记录:

You can use the levels filter on the handler to filter the log messages you would like to see in the handler. You can configure logging with the following CLI commands:

/subsystem=logging/periodic-rotating-file-handler=info-handler:add(named-formatter=json, file={relative-to=jboss.server.log.dir, path=info.log}, level=INFO, filter-spec=levels(INFO), suffix=".yyyy-MM-dd")
/subsystem=logging/periodic-rotating-file-handler=error-handler:add(named-formatter=json, file={relative-to=jboss.server.log.dir, path=error.log}, level=ERROR, suffix=".yyyy-MM-dd")
/subsystem=logging/logger=com.abc.api:add(handlers=[info-handler, error-handler])

注意我没有添加use-parent-handlers=false.这允许在您需要时仍将消息记录到 server.log 中.

Note I did not add the use-parent-handlers=false. This allows messages to still be logged into the server.log in case you need them.

这篇关于如何将信息日志和错误日志记录到 WILD FLY 服务器中的不同文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆