Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to configure log4j properly for custom struts action class?

Posted on 2008-10-15
4
2,085 Views
Last Modified: 2013-11-24
Hi,

We have an struts/ejb web application.
I migrated the application from WAS 5.1 to WAS 6.1

Our struts has a custome action class defined in web.xml as:

<servlet>
            <servlet-name>action</servlet-name>
            <servlet-class>
            com.x.y.z.struts.ActionServlet</servlet-class>
            <init-param>
                  <param-name>config</param-name>
                  <param-value>/WEB-INF/struts-config.xml</param-value>
            </init-param>
            <init-param>
                  <param-name>debug</param-name>
                  <param-value>2</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>false</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
</servlet>


com.x.y.z.struts.ActionServlet servlet directly extends the struts Action class.


The web app uses both commons-logging-1.0.3.jar and log4j-1.2.8.jar (in the web-inf/lib folder).


We configured the log4j.xml file as:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" threshold="null" xmlns:log4j="http://jakarta.apache.org/log4j/">
  <appender name="standardAppender" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="C:\\logs\\was\\application.log"/>
    <param name="DatePattern" value="yyyyMMdd"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="[%d{ISO8601}] %5p (%x) : %m%n"/>
    </layout>
  </appender>
    <appender name="synchAppender" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="C:\\logs\\was\\sas.log"/>
    <param name="DatePattern" value="yyyyMMdd"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="[%d{ISO8601}] %5p (%x) : %m%n"/>
    </layout>
  </appender>
  <logger name="application">
    <level value="debug"/>
    <appender-ref ref="standardAppender"/>
  </logger>
    <logger name="synch">
    <level value="trace"/>
    <appender-ref ref="synchAppender"/>
  </logger>
</log4j:configuration>



Now, the application does produce the log files and loggs the messages fine ...BUT ...
I get log4j warnings as:

[10/15/08 11:40:46:897 EDT] 0000001b SystemErr     R log4j:WARN No appenders could be found for logger (org.apache.struts.action.ActionServlet).
[10/15/08 11:40:46:897 EDT] 0000001b SystemErr     R log4j:WARN Please initialize the log4j system properly.

I can't seem to find what the problem here is; why is it giving the warning messages?

The log4j.xml and log4j.dtd files do get rightly placed under the web-inf/classes folder ...


Please let me know how to solve the warning messages for log4j?

Using RAD7/Java 5/ WAS 6.1

Thanks.
_Esam.
0
Comment
Question by:_Esam
  • 2
4 Comments
 
LVL 17

Expert Comment

by:sweetfa2
ID: 22725109
It obviously can't find the files.  Try moving them up one or two levels of directory.
0
 

Author Comment

by:_Esam
ID: 22726115
It does find the files as I already mentioned:
>>
Now, the application does produce the log files and loggs the messages fine ...BUT ...
I get log4j warnings as:

[10/15/08 11:40:46:897 EDT] 0000001b SystemErr     R log4j:WARN No appenders could be found for logger (org.apache.struts.action.ActionServlet).
[10/15/08 11:40:46:897 EDT] 0000001b SystemErr     R log4j:WARN Please initialize the log4j system properly.
<<

It works fine on WAS 5.1 but does this on WAS 6.1.
Obviously something is different here.

Thax.
_Esam
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 22728210
You have not defined the logger org.apache.struts.action.ActionServlet. You need to define it on log4j.xml

On WAS5.1, It appears to me that it might be using different log4j configration file
0
 

Accepted Solution

by:
_Esam earned 0 total points
ID: 24291395
I have not found any suitable answer to the question.
I will request to have this question deleted.

Thanks.
_Esam
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question