Solved

How to configure log4j properly for custom struts action class?

Posted on 2008-10-15
4
2,069 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
Comment Utility
It obviously can't find the files.  Try moving them up one or two levels of directory.
0
 

Author Comment

by:_Esam
Comment Utility
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
Comment Utility
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
Comment Utility
I have not found any suitable answer to the question.
I will request to have this question deleted.

Thanks.
_Esam
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now