此内容没有您所选择的语言版本。
5.5. Logging Sample Configurations
5.5.1. Sample XML Configuration for the Root Logger 复制链接链接已复制到粘贴板!
Procedure 5.1. Configure the Root Logger
Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <root-logger> <level name="INFO"/><subsystem xmlns="urn:jboss:domain:logging:1.2"> <root-logger> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow List
handlershandlersis a list of log handlers that are used by the root logger.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.2. Sample XML Configuration for a Log Category 复制链接链接已复制到粘贴板!
Procedure 5.2. Configure a Log Category
Define the Category
Use thecategoryproperty to specify the log category from which log messages will be captured.Theuse-parent-handlersis set to"true"by default. When set to"true", this category will use the log handlers of the root logger in addition to any other assigned handlers.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <logger category="com.company.accounts.rec" use-parent-handlers="true">
<subsystem xmlns="urn:jboss:domain:logging:1.2"> <logger category="com.company.accounts.rec" use-parent-handlers="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelpropertyUse thelevelproperty to set the maximum level of log message that the log category records.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <logger category="com.company.accounts.rec" use-parent-handlers="true"> <level name="WARN"/><subsystem xmlns="urn:jboss:domain:logging:1.2"> <logger category="com.company.accounts.rec" use-parent-handlers="true"> <level name="WARN"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow List
handlershandlersis a list of log handlers.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure 5.3. Configure the Console Log Handler
Add the Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.Whenautoflushis set to"true"the log messages will be sent to the handler's target immediately upon request.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true">
<subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log messages recorded.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/><subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
encodingOutputUseencodingto set the character encoding scheme to be used for the output.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/><subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
targetValueThetargetproperty defines the system output stream where the output of the log handler goes. This can beSystem.errfor the system error stream, orSystem.outfor the standard out stream.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/> <target value="System.out"/><subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/> <target value="System.out"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
filter-specPropertyThefilter-specproperty is an expression value that defines a filter. The example provided defines a filter that does not match a pattern:not(match("JBAS.*")).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the
formatterUseformatterto list the log formatter used by the log handler.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.4. Sample XML Configuration for a File Log Handler 复制链接链接已复制到粘贴板!
Procedure 5.4. Configure the File Log Handler
Add the File Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.Whenautoflushis set to"true"the log messages will be sent to the handler's target immediately upon request.<file-handler name="accounts-rec-trail" autoflush="true">
<file-handler name="accounts-rec-trail" autoflush="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/><file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
encodingOutputUseencodingto set the character encoding scheme to be used for the output.<file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/><file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
fileObjectThefileobject represents the file where the output of this log handler is written to. It has two configuration properties:relative-toandpath.Therelative-toproperty is the directory where the log file is written to. JBoss Enterprise Application Platform 6 file path variables can be specified here. Thejboss.server.log.dirvariable points to thelog/directory of the server.Thepathproperty 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 therelative-toproperty to determine the complete path.<file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/> <file relative-to="jboss.server.log.dir" path="accounts-rec-trail.log"/><file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/> <file relative-to="jboss.server.log.dir" path="accounts-rec-trail.log"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the
formatterUseformatterto list the log formatter used by the log handler.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
appendPropertyWhen theappendproperty 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 toappendrequire a server reboot to take effect.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure 5.5. Configure the Periodic Log Handler
Add the Periodic Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.Whenautoflushis set to"true"the log messages will be sent to the handler's target immediately upon request.<periodic-rotating-file-handler name="FILE" autoflush="true">
<periodic-rotating-file-handler name="FILE" autoflush="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<periodic-rotating-file-handler name="FILE" autoflush="true"> <level name="INFO"/>
<periodic-rotating-file-handler name="FILE" autoflush="true"> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
encodingOutputUseencodingto set the character encoding scheme to be used for the output.<periodic-rotating-file-handler name="FILE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/>
<periodic-rotating-file-handler name="FILE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the
formatterUseformatterto list the log formatter used by the log handler.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
fileObjectThefileobject represents the file where the output of this log handler is written to. It has two configuration properties:relative-toandpath.Therelative-toproperty is the directory where the log file is written to. JBoss Enterprise Application Platform 6 file path variables can be specified here. Thejboss.server.log.dirvariable points to thelog/directory of the server.Thepathproperty 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 therelative-toproperty to determine the complete path.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
suffixValueThesuffixis appended to the filename of the rotated logs and is used to determine the frequency of rotation. The format of thesuffixis a dot (.) followed by a date string, which is parsable by thejava.text.SimpleDateFormatclass. The log is rotated on the basis of the smallest time unit defined by thesuffix. For example,yyyy-MM-ddwill result in daily log rotation. See http://docs.oracle.com/javase/6/docs/api/index.html?java/text/SimpleDateFormat.htmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
appendPropertyWhen theappendproperty 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 toappendrequire a server reboot to take effect.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.6. Sample XML Configuration for a Size Log Handler 复制链接链接已复制到粘贴板!
Procedure 5.6. Configure the Size Log Handler
Add the Size Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.Whenautoflushis 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">
<size-rotating-file-handler name="accounts_debug" autoflush="false">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<size-rotating-file-handler name="accounts_debug" autoflush="false"> <level name="DEBUG"/>
<size-rotating-file-handler name="accounts_debug" autoflush="false"> <level name="DEBUG"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
encodingOutputUseencodingto 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"/>
<size-rotating-file-handler name="accounts_debug" autoflush="false"> <level name="DEBUG"/> <encoding value="UTF-8"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
fileObjectThefileobject represents the file where the output of this log handler is written to. It has two configuration properties:relative-toandpath.Therelative-toproperty is the directory where the log file is written to. JBoss Enterprise Application Platform 6 file path variables can be specified here. Thejboss.server.log.dirvariable points to thelog/directory of the server.Thepathproperty 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 therelative-toproperty 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"/>
<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 Copied! Toggle word wrap Toggle overflow Specify the
rotate-sizeValueThe maximum size that the log file can reach before it is rotated. A single character appended to the number indicates the size units:bfor bytes,kfor kilobytes,mfor megabytes,gfor gigabytes. For example:50mfor 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"/>
<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 Copied! Toggle word wrap Toggle overflow Set the
max-backup-indexNumberThe maximum number of rotated logs that are kept. When this number is reached, the oldest log is reused.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the
formatterUseformatterto list the log formatter used by the log handler.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
appendPropertyWhen theappendproperty 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 toappendrequire a server reboot to take effect.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.7. Sample XML Configuration for a Async Log Handler 复制链接链接已复制到粘贴板!
Procedure 5.7. Configure the Async Log Handler
Add the Async Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.<async-handler name="Async_NFS_handlers">
<async-handler name="Async_NFS_handlers">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<async-handler name="Async_NFS_handlers"> <level name="INFO"/>
<async-handler name="Async_NFS_handlers"> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
queue-lengthThequeue-lengthdefines the maximum number of log messages that will be held by this handler while waiting for sub-handlers to respond.<async-handler name="Async_NFS_handlers"> <level name="INFO"/> <queue-length value="512"/>
<async-handler name="Async_NFS_handlers"> <level name="INFO"/> <queue-length value="512"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Overflow Response
Theoverflow-actiondefines how this handler responds when its queue length is exceeded. This can be set toBLOCKorDISCARD.BLOCKmakes the logging application wait until there is available space in the queue. This is the same behavior as an non-async log handler.DISCARDallows the logging application to continue but the log message is deleted.<async-handler name="Async_NFS_handlers"> <level name="INFO"/> <queue-length value="512"/> <overflow-action value="block"/>
<async-handler name="Async_NFS_handlers"> <level name="INFO"/> <queue-length value="512"/> <overflow-action value="block"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow List
subhandlersThesubhandlerslist is the list of log handlers to which this async handler passes its log messages.Copy to Clipboard Copied! Toggle word wrap Toggle overflow