logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amit Vaidya" <amitvai...@infy.com>
Subject RE: Help needed : Log4J with servlets
Date Wed, 13 Jun 2001 10:04:58 GMT
Hi,

I'm using following XML file for configuring Log4J (thru' servlets)
---------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
	<appender name="STDOUT"
class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%5p [%t]
(%F:%L) - %m%n"/>
		</layout>
	</appender>
	<appender name="LogFile"
class="org.apache.log4j.RollingFileAppender">
		<param name="File" value="logFile.txt"/>
		<param name="MaxFileSize" value="100KB"/>
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="%p %t %c
- %m%n"/>
		</layout>
	</appender>
	<category name="assign4Servlet">
		<appender-ref ref="STDOUT"/>
		<appender-ref ref="LogFile"/>
		<priority value="DEBUG"/>
	</category>
	<root>
		<priority value="DEBUG"/>
	</root>
</log4j:configuration>
---------
The name of my servlet is 'assign4Servlet'. When the servlet is
executed, I get the following error message:
=========
log4j:ERROR No appenders could be found for category (assign4Servlet).
log4j:ERROR Please initialize the log4j system properly.
=========
Why am I getting this message inspite of having specified 2 appenders to
category 'assign4Servlet'

Regards,
Amit


________________________________________________________________________
Amit Vaidya  Infosys® Pune, India 
Tel : 91-2139-32801 (outside Pune) 95-2139-32801 (from Pune)  Ext : 4342




-----Original Message-----
From: Ceki Gülcü [mailto:cgu@qos.ch]
Sent: Wednesday, June 13, 2001 2:37 PM
To: LOG4J Users Mailing List
Subject: RE: Help needed : Log4J with servlets



Amit,

What's error being generated? Ceki

At 14:22 13.06.2001 +0530, you wrote:
>Hi,
>
>If following code is valid 
>Category cat = Category.getInstance(NameOfTheServlet.class.getName());
>
>then, could you please give me an example of how to use Log4J with
>servlets?
>I need to use XML file as configuration file which should be parsed
>thru' servlet
>and necessary logging should be done.
>
>Currently I've used the following code (inside doPost method):
>---------------
>                static Category cat =
>Category.getInstance(assign4Servlet.class.getName());
>
>                try
>                {
>                        URL url =
>getServletConfig().getServletContext().getResource("/sample1.xml");
>                        DocumentBuilderFactory factory =
>DocumentBuilderFactory.newInstance();
>                        factory.setValidating(true);
>                        DocumentBuilder builder =
>factory.newDocumentBuilder();
>                        Document doc =
>builder.parse(url.toExternalForm()); 
>        
>DOMConfigurator.configure(doc.getDocumentElement());
>                        --------------
>                        -------- some servlet code --------
>                        --------------
>                        cat.info("Inside doPost method of the
servlet");
>                        cat.debug("Inside doPost method of the
>servlet");
>
>
>                }
>                catch(ParserConfigurationException eP)
>                {
>
>                }
>                catch(SAXException eS)
>                {
>
>                }
>
>--------------------
>file sample1.xml is in the same directory as the servlet class file.
>But there is no log being generated.
>What could be the problem? 
>
>Thanks & regards,
>Amit
>
>_______________________________________________________________________
_
>Amit Vaidya  Infosys® Pune, India 
>Tel : 91-2139-32801 (outside Pune) 95-2139-32801 (from Pune)  Ext :
4342
>
>
>
>
>-----Original Message-----
>From: Ceki Gülcü [mailto:cgu@qos.ch]
>Sent: Wednesday, June 13, 2001 2:20 PM
>To: LOG4J Users Mailing List; log4j-user@jakarta.apache.org
>Subject: Re: Help needed : Log4J with servlets
>
>
>At 17:30 13.06.2001 +1000, SCOTT FARQUHAR wrote:
>>The problem is that Category takes a String, not a class.
>
>Hello Scott,
>
>Categoty.getInstance takes a string or a class. Assuming that the
>MyFooBar class is in the ch.qos package. The following a strictly
>equivalent:
>
> Category x = Category.getInstance("ch.qos.MyFooBar");
> Category x = Category.getInstance(MyFooBar.class.getName());
> Category x = Category.getInstance(MyFooBar.class);
>
>
>>Category cat = Category.getInstance(NameOfTheServlet.class.getName());
>>
>>If you turn off friendly error messages in IE, you would have been
able
>to see this error.
>>
>>Scott
>>
>>
>>>>> amitvaidya@infy.com 06/13/01 01:15pm >>>
>>Hi,
>> 
>>I'm trying to use log4J with servlets (running on weblogic)
>>When I try to create a category instance inside my servlet,
>>--------------
>>Category cat = Category.getInstance(NameOfTheServlet.class);
>>--------------
>>This causes internal server error. What exactly could be the problem?
>>I've imported the following packages in my servlet:
>>--------------
>>import org.apache.log4j.xml.DOMConfigurator;
>>import org.apache.log4j.Category;
>>import org.apache.log4j.Priority;
>>--------------
>>The java file compiles without any warnings or errors but the servlet 
>>during runtime gives 'Internal server error'.
>> 
>>I would really appreciate a sample code that illustrates the usage of
>>log4J with
>>servlets. 
>> 
>>Thanks & regards,
>>Amit
>>


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


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


Mime
View raw message