Log4j2.0 not working with Jboss 5

I have a problem with struts2 and log4j2.0. My program works fine, but log4j2.0 is not responding. Help me solve this problem.

im using the 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>

      

0


source to share


1 answer


I forgot what the default level is, but try setting it in as much detail as possible 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 option:



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

      

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

0


source







All Articles