14.5.5. 日志配置集配置示例

这个例子展示了日志配置集的配置以及使用它的应用程序。它也展示了 CLI 会话、生成的 XML 配置以及应用程序的 MANIFEST.MF 文件。
这个日志配置集示例具有下列特点:
  • 名称是 accounts-app-profile
  • 日志类别是 com.company.accounts.ejbs
  • 日志级别是 TRACE
  • 日志处理程序是使用 ejb-trace.log 的文件处理程序。

例 14.60. CLI 会话

localhost:bin user$ ./jboss-cli.sh -c
[standalone@localhost:9999 /] /subsystem=logging/logging-profile=accounts-app-profile:add
{"outcome" => "success"}

[standalone@localhost:9999 /] /subsystem=logging/logging-profile=accounts-app-profile/file-handler=ejb-trace-file:add(file={path=>"ejb-trace.log", "relative-to"=>"jboss.server.log.dir"})
{"outcome" => "success"}

[standalone@localhost:9999 /] /subsystem=logging/logging-profile=accounts-app-profile/file-handler=ejb-trace-file:write-attribute(name="level", value="DEBUG")
{"outcome" => "success"}

[standalone@localhost:9999 /] /subsystem=logging/logging-profile=accounts-app-profile/logger=com.company.accounts.ejbs:add(level=TRACE)
{"outcome" => "success"}

[standalone@localhost:9999 /] /subsystem=logging/logging-profile=accounts-app-profile/logger=com.company.accounts.ejbs:add-handler(name="ejb-trace-file")
{"outcome" => "success"}

[standalone@localhost:9999 /]

例 14.61. XML 配置

<logging-profiles>
   <logging-profile name="accounts-app-profile">
      <file-handler name="ejb-trace-file">
         <level name="DEBUG"/>
         <file relative-to="jboss.server.log.dir" path="ejb-trace.log"/>
      </file-handler>
      <logger category="com.company.accounts.ejbs">
         <level name="TRACE"/>
         <handlers>
            <handler name="ejb-trace-file"/>
         </handlers>
      </logger>
   </logging-profile>
</logging-profiles>

例 14.62. 应用程序的 MANIFEST.MF 文件

Manifest-Version: 1.0
Logging-Profile: accounts-app-profile