You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by hemant <xr...@yahoo.com> on 2002/03/28 16:30:18 UTC

Struts 1.1Beta and Log4J, "No appender" Issue

Fellow Strutters and Loggers,

I have a webapp using Struts1.0.2 and it works fine. Iam currently using Tomcat 4.0.2 and Log4J 1.1.3. I read about the enhancements in 1.1beta and decided to use it my webapp. 

I suddenly get the following... 

log4j: No appenders could be found for category (org.apache.commons.digester.Digester).
log4j: Please initialize the log4j system properly

I removed 1.1beta and rollbacked to my good ol 1.0.2 and everything works fine. 

Why is Struts 1.1beta messing with my Log4J configuration? (or am I missing something?). Please advise.


Thanks for your time
hemant










Re: Struts 1.1Beta and Log4J, "No appender" Issue

Posted by hemant <xr...@yahoo.com>.
Thanks Marcelo

I will try that at the end of the day and will post the result. Switching
back and forth between 1.0.2 and 1.1b is not as smooth as it seems with VA
3.5.3 and Tomcat 4.x.

Regards
hemant

----- Original Message -----
From: "Marcelo Vanzin" <va...@rededc.com.br>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, April 01, 2002 3:30 PM
Subject: Re: Struts 1.1Beta and Log4J, "No appender" Issue


> hemant wrote:
> > here is the servlet part of the web.xml you asked for..
>
> Modify the "load-on-startup" value so that the value attributed to your
> servlet is smaller than the one given to the ActionServlet.
>
> --
> []'s
> Marcelo Vanzin
> Touch Tecnologia
> vanza@rededc.com.br
> "Life is too short to drink cheap beer"
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts 1.1Beta and Log4J, "No appender" Issue

Posted by Marcelo Vanzin <va...@rededc.com.br>.
hemant wrote:
> here is the servlet part of the web.xml you asked for..

	Modify the "load-on-startup" value so that the value attributed to your 
servlet is smaller than the one given to the ActionServlet.

-- 
[]'s
Marcelo Vanzin
Touch Tecnologia
vanza@rededc.com.br
"Life is too short to drink cheap beer"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts 1.1Beta and Log4J, "No appender" Issue

Posted by hemant <xr...@yahoo.com>.
Marcelo

Thanks for your time,

here is the servlet part of the web.xml you asked for..

Regards
hemant
///////////////////////////////web.xml start
/////////////////////////////////////////////
<web-app>

  <!--StartupManager-->
  <servlet>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      <init-param>
        <param-name>LOG4J_CONFIG</param-name>

<param-value>/com/jny/operations/mplanning/mpi/properties/log4j.properties</
param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
  </servlet>


  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>application</param-name>

<param-value>com.jny.operations.mplanning.mpi.properties.ApplicationResource
s</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>validate</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

/////...................... more web.xml details.....
////////////////////////////////web.xml
end////////////////////////////////////////////


The following is my init method...

////////////////////////////////////init()
start///////////////////////////////////////////////
public void init()
{
    // insert code to initialize the servlet here
    // Testing Log4J...............................

        try
        {
             String configFile =
getServletConfig().getInitParameter("LOG4J_CONFIG");
            Logger logger = new Logger(configFile);
            }
    catch (Exception e)
        {
        System.out.println("The exception is " + e.toString());
    }

}
////////////////////////////////////init()
end///////////////////////////////////////////////

//////////////////////////////////Logger class
start////////////////////////////////////////////
public class Logger
{

    static Category cat = Category.getInstance("mpi");

public Logger(String log4jpath)
{
      try
            {

                if ((null != log4jpath) && (log4jpath.trim().length() > 0) )
                {
                Properties pp = new Properties();
                URL url = pp.getClass().getResource(log4jpath);
                PropertyConfigurator.configure(url);
            }
            else
                {
                BasicConfigurator.configure();
            }
        }
        catch (Exception e)
            {
            System.err.println("Error in Configuration: " + e);
        }
///////////////////////
// Lots of methods here for debug(), info(), etc for example...
//  public static void info(String message)
 //  {
  //  cat.info(message);
//   }
//////////////////////

    }

}
/////////////////////////////////Logger
End/////////////////////////////////////////////////////











----- Original Message -----
From: "Marcelo Vanzin" <va...@rededc.com.br>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, April 01, 2002 1:32 PM
Subject: Re: Struts 1.1Beta and Log4J, "No appender" Issue


>
> Could you post the part of your web.xml where the servlets are declared,
> and the init() method of your StartupManager servlet, so I could take a
> look at them?
>
> I have the same setup as you seem to have (a servlet loading the Log4j
> configuration prior to the ActionServlet loading) and I never get this
> error.
>
> hemant wrote:
> > I tried to load my StartupManager Servlet which loads the Log4J
> > configuration prior to ActionServlet load but in vain.
> >
> > I still get the following..
> >
> > log4j: No appenders could be found for category
> > (org.apache.commons.digester.Digester).
> > log4j: Please initialize the log4j system properly
>
>
> --
> []'s
> Marcelo Vanzin
> Touch Tecnologia
> vanza@rededc.com.br
> "Life is too short to drink cheap beer"
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts 1.1Beta and Log4J, "No appender" Issue

Posted by Marcelo Vanzin <va...@rededc.com.br>.
	Could you post the part of your web.xml where the servlets are declared, 
and the init() method of your StartupManager servlet, so I could take a 
look at them?

	I have the same setup as you seem to have (a servlet loading the Log4j 
configuration prior to the ActionServlet loading) and I never get this 
error.

hemant wrote:
> I tried to load my StartupManager Servlet which loads the Log4J
> configuration prior to ActionServlet load but in vain.
> 
> I still get the following..
> 
> log4j: No appenders could be found for category
> (org.apache.commons.digester.Digester).
> log4j: Please initialize the log4j system properly


-- 
[]'s
Marcelo Vanzin
Touch Tecnologia
vanza@rededc.com.br
"Life is too short to drink cheap beer"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts 1.1Beta and Log4J, "No appender" Issue

Posted by hemant <xr...@yahoo.com>.
Fellow Loggers,

The problem still recurs.
I tried to load my StartupManager Servlet which loads the Log4J
configuration prior to ActionServlet load but in vain.

I still get the following..

log4j: No appenders could be found for category
(org.apache.commons.digester.Digester).
log4j: Please initialize the log4j system properly

The above error seems to be simple to handle but there is an internal
mechanism that is trying to discover Log4J and is doing something with it
even before I load Log4J (via StartupManager Servlet) myself. If all I need
to do is to add an appender, which properties file is it looking for? and
where is it looking for? (/classes)??. It definitely is not looking at my
log4j.properties as I tried to add the appender there and it did not work.

Another question, slightly on a tangent though, I get a "Cannot find
ActionMappings or ActionFormBeans collection" while the same
struts-config.xml works fine with Struts 1.0.2

Please Advise
hemant








----- Original Message -----
From: "hemant" <xr...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, March 28, 2002 2:09 PM
Subject: Re: Struts 1.1Beta and Log4J, "No appender" Issue


> Marcelo
>
> Thanks, Will try to make sure that Log4J initializes prior to
ActionServlet
> load. Earlier, I had a Logger class which had a Category instance
> initialized in a static block. Looks like my Logger was loaded prior to
> ActionServlet with 1.0.2. Now, I guess I have to write a startup servlet
and
> load it prior to ActionServlet as you said.
>
> have a good weekend
> hemant
>
>
> public class Logger
> {
>         static Category category = Category.getInstance("mpi");
>     static {
>         try
>             {
>
>             String pc = CommonConstants.LOG4JPATH;
>             System.out.println("pc is " + pc);
>             if ((pc.trim().length() > 0) && (null != pc))
>                 {
>                 Properties pp = new Properties();
>                 URL url = pp.getClass().getResource(pc);
>                 PropertyConfigurator.configure(url);
>             }
>             else
>                 {
>                 BasicConfigurator.configure();
>             }
>         }
>         catch (Exception e)
>             {
>             System.err.println("Error in Configuration: " + e);
>         }
>     }
>
> ///////////////////////
> // Lots of methods here for debug(), info(), etc
> //////////////////////
>
> }
>
>
>
>
> -----------------------------------------------------------
>
> > hemant wrote:
> > > The Log4J configuration loaded property when I used Struts 1.0.2. If
it
> > > worked then, shouldn't it work now with struts 1.1beta?
> >
> > It worked with 1.0.2, but Struts did not use the commons-logging package
> > then, so the log messages weren't printed through Log4j, which is the
> > case now.
> >
> > It seems that you initialize the log4j configuration after the Struts'
> > ActionServlet loads, so when the ActionServlet (and the Digester, and
> > Beanutils, etc) try to log and log4j is not yet configured, you get that
> > error.
> >
> > I have a servlet that loads some configuration for my application. I've
> > set it up so that it loads before the Struts' ActionServlet, so that the
> > log4j system is properly initialized when called. Try do do something
> > similar.
> >
> > --
> > []'s
> > Marcelo Vanzin
> > Touch Tecnologia
> > vanza@rededc.com.br
> > "Life is too short to drink cheap beer"
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts 1.1Beta and Log4J, "No appender" Issue

Posted by hemant <xr...@yahoo.com>.
Marcelo

Thanks, Will try to make sure that Log4J initializes prior to ActionServlet
load. Earlier, I had a Logger class which had a Category instance
initialized in a static block. Looks like my Logger was loaded prior to
ActionServlet with 1.0.2. Now, I guess I have to write a startup servlet and
load it prior to ActionServlet as you said.

have a good weekend
hemant


public class Logger
{
        static Category category = Category.getInstance("mpi");
    static {
        try
            {

            String pc = CommonConstants.LOG4JPATH;
            System.out.println("pc is " + pc);
            if ((pc.trim().length() > 0) && (null != pc))
                {
                Properties pp = new Properties();
                URL url = pp.getClass().getResource(pc);
                PropertyConfigurator.configure(url);
            }
            else
                {
                BasicConfigurator.configure();
            }
        }
        catch (Exception e)
            {
            System.err.println("Error in Configuration: " + e);
        }
    }

///////////////////////
// Lots of methods here for debug(), info(), etc
//////////////////////

}




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

> hemant wrote:
> > The Log4J configuration loaded property when I used Struts 1.0.2. If it
> > worked then, shouldn't it work now with struts 1.1beta?
>
> It worked with 1.0.2, but Struts did not use the commons-logging package
> then, so the log messages weren't printed through Log4j, which is the
> case now.
>
> It seems that you initialize the log4j configuration after the Struts'
> ActionServlet loads, so when the ActionServlet (and the Digester, and
> Beanutils, etc) try to log and log4j is not yet configured, you get that
> error.
>
> I have a servlet that loads some configuration for my application. I've
> set it up so that it loads before the Struts' ActionServlet, so that the
> log4j system is properly initialized when called. Try do do something
> similar.
>
> --
> []'s
> Marcelo Vanzin
> Touch Tecnologia
> vanza@rededc.com.br
> "Life is too short to drink cheap beer"
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts 1.1Beta and Log4J, "No appender" Issue

Posted by Marcelo Vanzin <va...@rededc.com.br>.
hemant wrote:
> The Log4J configuration loaded property when I used Struts 1.0.2. If it
> worked then, shouldn't it work now with struts 1.1beta?

	It worked with 1.0.2, but Struts did not use the commons-logging package 
then, so the log messages weren't printed through Log4j, which is the 
case now.

	It seems that you initialize the log4j configuration after the Struts' 
ActionServlet loads, so when the ActionServlet (and the Digester, and 
Beanutils, etc) try to log and log4j is not yet configured, you get that 
error.

	I have a servlet that loads some configuration for my application. I've 
set it up so that it loads before the Struts' ActionServlet, so that the 
log4j system is properly initialized when called. Try do do something 
similar.

-- 
[]'s
Marcelo Vanzin
Touch Tecnologia
vanza@rededc.com.br
"Life is too short to drink cheap beer"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts 1.1Beta and Log4J, "No appender" Issue

Posted by hemant <xr...@yahoo.com>.
Marcelo ,

Thanks for your response,

The Log4J configuration loaded property when I used Struts 1.0.2. If it
worked then, shouldn't it work now with struts 1.1beta?
Yes, I did look at the Logging class for Log4J, Log4JCategoryLog. but, it
should not interfere with my Log4J settings unless I specifically want it
to.

Regards
hemant








---- Original Message -----
From: "Marcelo Vanzin" <va...@rededc.com.br>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, March 28, 2002 11:48 AM
Subject: Re: Struts 1.1Beta and Log4J, "No appender" Issue


> hemant wrote:
> > log4j: No appenders could be found for category
> > (org.apache.commons.digester.Digester).
> > log4j: Please initialize the log4j system properly
>
> Struts 1.1b is using the commons-logging package for logging, and in your
> case it is falling back to the Log4j system.
>
> It seems that your Log4j configuration is not being loaded before the
> ActionServlet is loaded, so you get this configuration error from Log4j.
>
> Try doing the Log4j initialization before the ActionServlet
initialization.
>
> --
> []'s
> Marcelo Vanzin
> Touch Tecnologia
> vanza@rededc.com.br
> "Life is too short to drink cheap beer"
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts 1.1Beta and Log4J, "No appender" Issue

Posted by Marcelo Vanzin <va...@rededc.com.br>.
hemant wrote:
> log4j: No appenders could be found for category
> (org.apache.commons.digester.Digester).
> log4j: Please initialize the log4j system properly

	Struts 1.1b is using the commons-logging package for logging, and in your 
case it is falling back to the Log4j system.

	It seems that your Log4j configuration is not being loaded before the 
ActionServlet is loaded, so you get this configuration error from Log4j.

	Try doing the Log4j initialization before the ActionServlet initialization.

-- 
[]'s
Marcelo Vanzin
Touch Tecnologia
vanza@rededc.com.br
"Life is too short to drink cheap beer"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>