1

我在standalone.xml 文件中为具有相同名称的类别定义了两个处理程序,如下所示

<logger category="ab.cd" use-parent-handlers="false">
            <level name="DEBUG" />
            <handlers>
                <handler name="abDebug" />
            </handlers>
        </logger>
<logger category="ab.cd" use-parent-handlers="true">
                <level name="WARN" />
                <handlers>
                    <handler name="abWarning" />
                </handlers>
            </logger>

但是当我尝试运行 jboss 7 时出现异常

 14:28:08,090 ERROR [org.jboss.as.server] JBAS015956: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration
    at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:141) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.server.ServerService.boot(ServerService.java:266) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:155) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_09]
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[143,4]
Message: JBAS014664: An element of this type named 'ab.cd' has already been declared
    at org.jboss.as.controller.parsing.ParseUtils.duplicateNamedElement(ParseUtils.java:235) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.logging.LoggingSubsystemParser.parseLoggerElement(LoggingSubsystemParser.java:229)
    at org.jboss.as.logging.LoggingSubsystemParser.readElement(LoggingSubsystemParser.java:149)
    at org.jboss.as.logging.LoggingSubsystemParser.readElement(LoggingSubsystemParser.java:113)
    at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
    at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
    at org.jboss.as.server.parsing.StandaloneXml.parseServerProfile(StandaloneXml.java:894) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.server.parsing.StandaloneXml.readServerElement_1_1(StandaloneXml.java:330) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:127) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:100) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
    at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
    at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:133) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
    ... 3 more

所以,我想知道这可能有两个相同类别的记录器吗?如果不是,那么在这种情况下如何将数据发送到两个不同的处理程序?

4

1 回答 1

2

您不能定义两个具有相同类别的记录器。记录器如何知道它应该使用哪个级别?您最好使用一个没有设置级别的记录器,并使用处理程序来设置您想要记录的级别。

类似于以下内容:

<file-handler name="abDebug" auto-flush="true">
    <level name="DEBUG"/>
    <file relative-to="jboss.server.log.dir" path="abDebug.log"/>
    <append value="true"/>
</file-handler>
<file-handler name="abWarning" auto-flush="true">
    <level name="WARN"/>
    <file relative-to="jboss.server.log.dir" path="abWarning.log"/>
    <append value="true"/>
</file-handler>

<logger category="ab.cd">
    <handlers>
        <handler name="abDebug" />
        <handler name="abWarning" />
    </handlers>
</logger>
于 2012-11-15T16:35:51.547 回答