You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Chopra, Sumeet (Cognizant)" <CS...@cal.cognizant.com> on 2003/05/08 18:14:12 UTC

HI

HI,

I am using commons-logging and Log4J .
I am using them on WebLogic 8.1b.

I have kept the commons-logging.properties file
in /WEB-INF/classes with this text
************************************************************************************************
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
************************************************************************************************

and I have also placed LoggingConfigurationFile.xml for Log4J
which has the following contents.

************************************************************************************************
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

  <log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/">

	<appender name="A1" class="org.apache.log4j.FileAppender">
            <param name="File"   value="D:/bea/user_projects/CheckFreeDomain/applications/CheckFree/logs/SimpleLog.log" />
            <param name="Append" value="true" />	    	
            <layout class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d{DATE} %-6r %-5p %30.30c %x - %m\n" />
            </layout>	    
	</appender>
	<appender name="A2" class="org.apache.log4j.FileAppender">
		<param name="File"   value="D:/bea/user_projects/CheckFreeDomain/applications/CheckFree/logs/AuditTrail.log" />
		<param name="Append" value="true" />	    	
	        <layout class="org.apache.log4j.PatternLayout">
		  <param name="ConversionPattern" value="%d{DATE} %-6r %-5p %30.30c %x - %m\n"/>
	        </layout>	    
	</appender>
	
	
	<category name="checkFree">
	    <priority value="debug" />
	    <appender-ref ref="A1" />
	</category>
	
	<category name="checkFree">
	    <priority value="debug" />
	    <appender-ref ref="A2" />
	</category>
	
	
	<root>
	    <!-- The following level element is not necessary since the -->
	    <!-- level of the root level is set to DEBUG by default.    -->
	    <level value ="INFO"/>
	    <appender-ref ref="A1" />
	    <appender-ref ref="A2" />
	</root>
  </log4j:configuration>
*******************************************************************************************************************************************

and I am calling log method from a class MyApp which is as :

*****************************************************************************************
package checkFree;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.*;


public class MyApp {

    private  static Log log = LogFactory.getLog(MyApp.class);;
    public void toPrint()
    {
       try
       {
		   //log = LogFactory.getLog("checkFree.MyApp");

		   log.fatal("This is  fatal mesage from MyApp");
	   }
	   catch(LogConfigurationException lce)
	   {
		   lce.printStackTrace();
	   }
     }
 }

*****************************************************************************************

toPrint() method is called from a JSP file after instaitating MyApp.

But I am getting this error.

##############################################

log4j:WARN No appenders could be found for logger (checkFree.MyApp).
log4j:WARN Please initialize the log4j system properly.

Can someone please tell me where I am going wrong ?


Thanks in advance.

Thanks and Regards,
Sumeet Chopra.



Re: HI

Posted by Mohan Kishore <mo...@yahoo.com>.
This is a question for the commons-user list (not dev list)

Try out these 2 approaches:
(1) renaming the xml file to log4j.xml
OR
(2) set a System Property: log4j.configuration pointing towards your
configuration file (defaults to log4j.properties)
See: http://jakarta.apache.org/log4j/docs/manual.html#defaultInit

If both these do not work, first try using log4j without commons-logging. Until
that works, you cannot expect commons-logging to make it work. Might have to
post in log4j mailing list...

--- "Chopra, Sumeet (Cognizant)" <CS...@cal.cognizant.com> wrote:
> HI,
> 
> I am using commons-logging and Log4J .
> I am using them on WebLogic 8.1b.
> 
> I have kept the commons-logging.properties file
> in /WEB-INF/classes with this text
>
************************************************************************************************
> org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
>
************************************************************************************************
> 
> and I have also placed LoggingConfigurationFile.xml for Log4J
> which has the following contents.
> 
>
************************************************************************************************
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> 
>   <log4j:configuration debug="true"
> xmlns:log4j="http://jakarta.apache.org/log4j/">
> 
> 	<appender name="A1" class="org.apache.log4j.FileAppender">
>             <param name="File"  
>
value="D:/bea/user_projects/CheckFreeDomain/applications/CheckFree/logs/SimpleLog.log"
> />
>             <param name="Append" value="true" />	    	
>             <layout class="org.apache.log4j.PatternLayout">
> 		<param name="ConversionPattern" value="%d{DATE} %-6r %-5p %30.30c %x -
> %m\n" />
>             </layout>	    
> 	</appender>
> 	<appender name="A2" class="org.apache.log4j.FileAppender">
> 		<param name="File"  
>
value="D:/bea/user_projects/CheckFreeDomain/applications/CheckFree/logs/AuditTrail.log"
> />
> 		<param name="Append" value="true" />	    	
> 	        <layout class="org.apache.log4j.PatternLayout">
> 		  <param name="ConversionPattern" value="%d{DATE} %-6r %-5p %30.30c %x -
> %m\n"/>
> 	        </layout>	    
> 	</appender>
> 	
> 	
> 	<category name="checkFree">
> 	    <priority value="debug" />
> 	    <appender-ref ref="A1" />
> 	</category>
> 	
> 	<category name="checkFree">
> 	    <priority value="debug" />
> 	    <appender-ref ref="A2" />
> 	</category>
> 	
> 	
> 	<root>
> 	    <!-- The following level element is not necessary since the -->
> 	    <!-- level of the root level is set to DEBUG by default.    -->
> 	    <level value ="INFO"/>
> 	    <appender-ref ref="A1" />
> 	    <appender-ref ref="A2" />
> 	</root>
>   </log4j:configuration>
>
*******************************************************************************************************************************************
> 
> and I am calling log method from a class MyApp which is as :
> 
>
*****************************************************************************************
> package checkFree;
> 
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.commons.logging.*;
> 
> 
> public class MyApp {
> 
>     private  static Log log = LogFactory.getLog(MyApp.class);;
>     public void toPrint()
>     {
>        try
>        {
> 		   //log = LogFactory.getLog("checkFree.MyApp");
> 
> 		   log.fatal("This is  fatal mesage from MyApp");
> 	   }
> 	   catch(LogConfigurationException lce)
> 	   {
> 		   lce.printStackTrace();
> 	   }
>      }
>  }
> 
>
*****************************************************************************************
> 
> toPrint() method is called from a JSP file after instaitating MyApp.
> 
> But I am getting this error.
> 
> ##############################################
> 
> log4j:WARN No appenders could be found for logger (checkFree.MyApp).
> log4j:WARN Please initialize the log4j system properly.
> 
> Can someone please tell me where I am going wrong ?
> 
> 
> Thanks in advance.
> 
> Thanks and Regards,
> Sumeet Chopra.
> 
> 
> > ****** Message from InterScan E-Mail VirusWall NT ******
> 
> ** No virus found in attached file noname.htm
> ** No virus found in attached file noname.htm
> 
> No Virus detected in the attached file(s).
> *****************     End of message     ***************
> 
> 
> > This e-mail and any files transmitted with it are for the sole use of the
> intended 
> recipient(s) and may contain confidential and privileged information. If you
> are not the 
> intended recipient, please contact the sender by reply e-mail and destroy all
> copies of 
> the original message. 
> Any unauthorised review, use, disclosure, dissemination, forwarding, printing
> or copying 
> of this email or any action taken in reliance on this e-mail is strictly
> prohibited and 
> may be unlawful.
> 
>           Visit us at http://www.cognizant.com
> 
> > ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org