在jboss eap 6.3或jboss eap 6.3中禁用默认日志配置log4j配置不应该包含stdout语句吗?

时间:2015-11-20 09:18:35

标签: java log4j jboss-eap-6

下面是我的logconfig.xml文件,我配置了日志,问题在这里我不希望stdout文件中的任何myLogs.log语句

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="null" threshold="null">
<appender name="INFO_FILE" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="mypath/myLogs.log"/>  
        <param name="DatePattern" value="'.'MM-dd-yy"/>
        <layout class="class path here">
            <param name="ConversionPattern" value="%d{ISO8601} %c{2} %m%n"/>
        </layout>
    </appender>

    <root>
        <level value="INFO" />
        <appender-ref ref="INFO_FILE"/>
    </root>
</log4j:configuration>

myLogs.log这个文件包含stdout日志,但是我不想要stdout语句,这个文件应该只包含除stdout之外的其他语句

2015-11-20 02:14:08,829 stdout setSessionContext()
2015-11-20 02:14:08,830 stdout ejbCreate()
2015-11-20 02:14:08,830 stdout getNewsRowSet()
2015-11-20 02:14:08,831 stdout newbean1
2015-11-20 02:14:08,831 stdout newbean2
2015-11-20 02:14:08,832 stdout newbean3
2015-11-20 02:14:08,832 stdout newbean4

1 个答案:

答案 0 :(得分:0)

您可以从subsystem文件中删除日志记录configuration/domain.xml。它将禁用jboss eap's默认日志记录,您的配置将起作用

    <subsystem xmlns="urn:jboss:domain:logging:1.4">
        <console-handler name="CONSOLE">
            <level name="INFO"/>
            <formatter>
                <named-formatter name="COLOR-PATTERN"/>
            </formatter>
        </console-handler>
        <periodic-rotating-file-handler name="FILE" autoflush="true">
            <formatter>
                <named-formatter name="PATTERN"/>
            </formatter>
            <file relative-to="jboss.server.log.dir" path="server.log"/>
            <suffix value=".yyyy-MM-dd"/>
            <append value="true"/>
        </periodic-rotating-file-handler>
        <logger category="com.arjuna">
            <level name="WARN"/>
        </logger>
        <logger category="org.apache.tomcat.util.modeler">
            <level name="WARN"/>
        </logger>
        <logger category="org.jboss.as.config">
            <level name="DEBUG"/>
        </logger>
        <logger category="sun.rmi">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb.config">
            <level name="ERROR"/>
        </logger>
        <root-logger>
            <level name="INFO"/>
            <handlers>
                <handler name="CONSOLE"/>
                <handler name="FILE"/>
            </handlers>
        </root-logger>
        <formatter name="PATTERN">
            <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
        </formatter>
        <formatter name="COLOR-PATTERN">
            <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
        </formatter>
    </subsystem>