此内容没有您所选择的语言版本。

5.5.6. Sample XML Configuration for a Size Log Handler


The following procedure demonstrates a sample configuration for a size log handler.

Procedure 5.6. Configure the Size Log Handler

  1. Add the Size Log Handler Identifier Information

    The name property sets the unique identifier for this log handler.
    When autoflush is set to "true" the log messages will be sent to the handler's target immediately upon request.
    <size-rotating-file-handler name="accounts_debug" autoflush="false">
    
    Copy to Clipboard Toggle word wrap
  2. Set the level Property

    The level property sets the maximum level of log message that the root logger records.
    <size-rotating-file-handler name="accounts_debug" autoflush="false">
       <level name="DEBUG"/>
    
    Copy to Clipboard Toggle word wrap
  3. Set the encoding Output

    Use encoding to set the character encoding scheme to be used for the output.
    <size-rotating-file-handler name="accounts_debug" autoflush="false">
       <level name="DEBUG"/>
       <encoding value="UTF-8"/>
    
    Copy to Clipboard Toggle word wrap
  4. Set the file Object

    The file object represents the file where the output of this log handler is written to. It has two configuration properties: relative-to and path.
    The relative-to property is the directory where the log file is written to. JBoss Enterprise Application Platform 6 file path variables can be specified here. The jboss.server.log.dir variable points to the log/ directory of the server.
    The path property is the name of the file where the log messages will be written. It is a relative path name that is appended to the value of the relative-to property to determine the complete path.
    <size-rotating-file-handler name="accounts_debug" autoflush="false">
       <level name="DEBUG"/>
       <encoding value="UTF-8"/>
       <file relative-to="jboss.server.log.dir" path="accounts-debug.log"/>
    
    Copy to Clipboard Toggle word wrap
  5. Specify the rotate-size Value

    The maximum size that the log file can reach before it is rotated. A single character appended to the number indicates the size units: b for bytes, k for kilobytes, m for megabytes, g for gigabytes. For example: 50m for 50 megabytes.
    <size-rotating-file-handler name="accounts_debug" autoflush="false">
       <level name="DEBUG"/>
       <encoding value="UTF-8"/>
       <file relative-to="jboss.server.log.dir" path="accounts-debug.log"/>
       <rotate-size value="500k"/>
    
    Copy to Clipboard Toggle word wrap
  6. Set the max-backup-index Number

    The maximum number of rotated logs that are kept. When this number is reached, the oldest log is reused.
    <size-rotating-file-handler name="accounts_debug" autoflush="false">
       <level name="DEBUG"/>
       <encoding value="UTF-8"/>
       <file relative-to="jboss.server.log.dir" path="accounts-debug.log"/>
       <rotate-size value="500k"/>
       <max-backup-index value="5"/>
    
    Copy to Clipboard Toggle word wrap
  7. Specify the formatter

    Use formatter to list the log formatter used by the log handler.
    <size-rotating-file-handler name="accounts_debug" autoflush="false">
       <level name="DEBUG"/>
       <encoding value="UTF-8"/>
       <file relative-to="jboss.server.log.dir" path="accounts-debug.log"/>
       <rotate-size value="500k"/>
       <max-backup-index value="5"/>
       <formatter>
            <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
        </formatter>
    
    Copy to Clipboard Toggle word wrap
  8. Set the append Property

    When the append property is set to "true", all messages written by this handler will be appended to an existing file. If set to "false" a new file will be created each time the application server launches. Changes to append require a server reboot to take effect.
    <size-rotating-file-handler name="accounts_debug" autoflush="false">
       <level name="DEBUG"/>
       <encoding value="UTF-8"/>
       <file relative-to="jboss.server.log.dir" path="accounts-debug.log"/>
       <rotate-size value="500k"/>
       <max-backup-index value="5"/>
       <formatter>
            <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
        </formatter>
       <append value="true"/>
    </size-rotating-file-handler>
    
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat