Discussions

Web tier: servlets, JSP, Web frameworks: Problem in logging messages using struts on weblogic

  1. I am using Struts 1.1 on Weblogic Aplication Server.
    I am logging messages using log4j.But I am getting the foloeing error when I have started the server.
    log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources).
    log4j:WARN Please initialize the log4j system properly.

    I would be happy if any one of you could help me in solving the problem.

    Thanks & Regards,
    Raghavendra.

    Threaded Messages (10)

  2. log4j[ Go to top ]

    Hi,

    Looks like Log4J failed to locate the log4j.properties file in the class path, check if you have it in your classpath.

    Ash
  3. log4j[ Go to top ]

    I have included massage-resources tag in struts-config.xml as follows:
    <message-resources parameter="com.raghu.struts.log4j>
    and placed the log4j.properties file in
    WEB-INF > classes > com > raghu > struts folder.
    Note:- The above gives the directory structure.

    Can you please say me how to set classpath. I am developing in Eclipse IDE without using eclipse easy struts plugins.

    Thanks for your response.
  4. None[ Go to top ]

    Hi,

    You can either set the folder where your properties file is in the server classpath it is not recommended if you have EJB and WEB classes both referring to it,but an easy wayout.
    Place log4j.jar in web-INF/lib or directly in server classpath.

    Ash
  5. Not able to solve[ Go to top ]

    I was not able to solve the problem even by this method.
  6. Not able to solve[ Go to top ]

    Make sure your Eclipse project's classpath can "see" the log4j jar file (in your Project's properties, go to the "Java Build Path" item and click on the Libraries tab). This will help avoid development-time errors.

    Make sure you have a log4j.properties file somewhere that is accessible by your application at runtime (WEB-INF/classes is an OK place to put it).

    Lastly, ensure that when you build your app, the log4j jar file is in the WEB-INF/lib directory of your application.

    Shouldn't need anything else. No need to tell Struts about it.
    Andy
  7. not solved[ Go to top ]

    I am able to run the application, but the following error is still continuing in the server console window.

    log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources).
    log4j:WARN Please initialize the log4j system properly.


    What should be the content of log4j.properties file.
    Can any of you help me.

    Thanks & Regards,
    Raghavendra
  8. I had the same problem as you until I realized that my log4j.xml file only included the packages for my application:

    <logger name="com.foo">
        <level value="debug"/>
        <appender-ref ref="DEBUG"/>
        <appender-ref ref="INFO"/>
        <appender-ref ref="WARN"/>
        <appender-ref ref="ERROR"/>
        <appender-ref ref="FATAL"/>
    </logger>

    I just added another logger entry:

    <logger name="org.apache">
        <level value="debug"/>
        <appender-ref ref="DEBUG"/>
        <appender-ref ref="INFO"/>
        <appender-ref ref="WARN"/>
        <appender-ref ref="ERROR"/>
        <appender-ref ref="FATAL"/>
    </logger>

    And everything was fine. This does include all Apache debugging messages in your logs. If you don't like this, you can easily specify different appenders for those messages from Apache.
  9. Problem solved[ Go to top ]

    Thanks David,

    My Problem is solved by following your method.

    Thanks a lot dear friend.

    Regards,
    Raghavendra
  10. Hi, could you give the equavalent to this if I am using properties file (resource bundle) to configure instead of XML.

    I tried

    log4j.org.apache=DEBUG, stdout

    Its not working, I am still getting the same warning

    This is urgent :-) thanks
    Vijay Kumar
  11. you can eliminate this by using a init servlet. public void init() throws ServletException { // Call the super class initialization try { //XMA base configuration DOMConfigurator.configure("c:/myapp/log4j.xml"); //property file base configuration PropertyConfigurator.configure(("c:/myapp/log4j.properties"); } catch (ServletException e) { e.printStackTrace(); // m_cLog.error(e); throw(e); } }