users@glassfish.java.net

Re: Help with setting up Slf4j/Log4j in a web app running on Glassfish v4

From: Ryan Lubke <ryan.lubke_at_oracle.com>
Date: Fri, 21 Jun 2013 09:10:25 -0700

It looks like there's more than one copy of log4j on the classpath.

A possible quick/dirty solution would be to disable classloader
delegation in your application by including a glassfish-web.xml in
/WEB-INF :

-------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish
Application Server 3.1 Servlet 3.0//EN"
         "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<class-loader delegate="false" />
</glassfish-web-app>

-------------------------------------------

John McDonnell wrote:
> Hi all,
>
> I have recently started using GF v4 (GlassFish Server Open Source
> Edition 4.0 (build 89) to be exact), and as part of my initial
> investigation I attempted to take an application that I know runs in
> Tomcat, and migrate it over to GF v4.
>
>
> I'm having an issue with getting my logs for the application to show
> up, where when I start an application I receive the following error:
> SEVERE: log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is
> not assignable to a "org.apache.log4j.Appender" variable.
> SEVERE: log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
> SEVERE: log4j:ERROR [WebappClassLoader (delegate=true;
> repositories=WEB-INF/classes/)] whereas object of type
> SEVERE: log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by
> [WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)].
> SEVERE: log4j:ERROR Could not instantiate appender named "R".
> SEVERE: log4j:WARN No appenders could be found for logger
> (org.jboss.logging).
> SEVERE: log4j:WARN Please initialize the log4j system properly.
> SEVERE: log4j:WARN See
> http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
>
>
> My maven dependency is declared as:
> <dependency>
> <groupId>org.slf4j</groupId>
> <artifactId>slf4j-log4j12</artifactId>
> <version>1.7.5</version>
> </dependency>
>
> Anyone have any ideas about this error?
>
> --
> John