Log4j2.0 is not working with Jboss 5

2019-09-10 17:03发布

i have issue with struts2 and log4j2.0 My program working properly but log4j2.0 is not respond pls help me to solve dis..

im using following jar: 1.log4j-core-2.0-beta8 2.log4j-api-2.0-beta8 3.log4j-web-2.0-beta2

my log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration strict="true" schema="Log4J-V2.0.xsd" status="OFF" monitorInterval="300"> 

    <appenders>
        <Console name="CONSOLE" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
        </Console>
        <File name="MyFile" fileName="Logger/knight.log">
            <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
        </File>
    </appenders>
    <loggers>       
        <root>
            <appender-ref ref="CONSOLE" />
            <appender-ref ref="MyFile" />
        </root>
    </loggers>
</configuration>

my web.xml

<?xml version="1.0" encoding="UTF-8"?>
    <display-name>Struts2_Verified</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>

    </welcome-file-list>
     <context-param>  
       <param-name>log4jConfiguration</param-name>
       <param-value>log4j2.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.apache.logging.log4j.core.web.Log4jContextListener</listener-class>
    </listener>
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

1条回答
仙女界的扛把子
2楼-- · 2019-09-10 17:21

I forgot what the default level is, but try setting it as verbose as possible at first.

    <root level="TRACE">
        <appender-ref ref="CONSOLE" level="DEBUG" /> <!-- can have their own level -->
        <appender-ref ref="MyFile" />
    </root>

Also, to see if there is a problem with the log4j2 configuration, use this setting:

    <configuration status="TRACE" monitorInterval="300">

If the above does not help, can you raise a Jira ticket for this on the log4j-2 issue tracker? (https://issues.apache.org/jira/browse/LOG4J2) The log4j team should be able to help out.

查看更多
登录 后发表回答