ERROR StatusLogger Unable to lookup java:comp/env/log4j/context-name in JBoss EAP 6
Issue
- We are trying to configure log4j2 in our application using the servlet listener as shown below but are getting the error logged as shown below:
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
@javax.jws.WebService
public class HelloBean {
private Logger log = LogManager.getLogger();
}
<?xml version='1.0' encoding='UTF-8'?>
<web-app version="2.5"
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" >
<env-entry>
<description>Sets the logging context for the web-app</description>
<env-entry-name>log4j/context-name</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>test</env-entry-value>
</env-entry>
<context-param>
<param-name>isLog4jContextSelectorNamed</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>log4jContextName</param-name>
<param-value>test</param-value>
</context-param>
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file:///${jboss.server.config.dir}/log4j2.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener>
...
...
</web-app>
16:34:33,709 ERROR [stderr] (MSC service thread 1-5) ERROR StatusLogger Unable to lookup java:comp/env/log4j/context-name
16:34:33,728 ERROR [stderr] (MSC service thread 1-5) ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 6.x
- Apache Log4j2
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.