?
Solved

How to configure log4j properly for custom struts action class?

Posted on 2008-10-15
4
Medium Priority
?
2,098 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
[X]
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
  • 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Simple Linear Regression
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

771 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