Log4j2.0 is not working with Jboss 5

与世无争的帅哥 提交于 2020-01-17 08:32:12

问题


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:


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.



来源:https://stackoverflow.com/questions/17834646/log4j2-0-is-not-working-with-jboss-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!