Before adding the parameter context and Log4jConfigListener for Log4j2me, I had all the logs listed in the catalina.out file .
So now I am trying to configure log4jfor my web application.
In I added the necessary configuration. web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>etl-service</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>myprofile</param-value>
</context-param>
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>/WEB-INF/classes/log4j2.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
</web-app>
log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="trace" strict="true" name="XMLConfigTest"
packages="">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<RollingRandomAccessFile name="RollingRandomAccessFileDebug" fileName="/local/deploy/logs/debug.log"
filePattern="logs/$${date:yyyy-MM}/etl-%d{MM-dd-yyyy}-%i.log.gz"
immediateFlush="false"
append="false">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingRandomAccessFile>
<RollingRandomAccessFile name="RollingRandomAccessFile" fileName="/local/deploy/logs/info.log"
filePattern="logs/$${date:yyyy-MM}/etl-%d{MM-dd-yyyy}-%i.log.gz"
immediateFlush="false"
append="false">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="TRACE">
<AppenderRef ref="RollingRandomAccessFileDebug" level="DEBUG"/>
<AppenderRef ref="RollingRandomAccessFile" level="INFO"/>
<AppenderRef ref="Console" level="TRACE"/>
</Root>
</Loggers>
</Configuration>
But at the moment I have the following error:
ERROR Unable to access WEB-INF/classes/log4j2.xml java.lang.IllegalArgumentException: URI is not absolute
Perhaps someone has already encountered such a problem. Also I tried instead of adding /WEB-INF/classes/log4j.xmluseclasspath*:log4j.xml
And had a mistake java.net.URISyntaxException: Illegal character in schema name at 9 index: classpath*:log4j.xml
UPDATE:
We only need to add the descriptor file name, and it works.
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>log4j2.xml</param-value>
</context-param>
, catalina.out. log4j.