Hi Javier,
Thanks a lot for replying to my question. We are using this statement for 
obtaining the Logger object
Logger logger = Logger.getLogger(MyClass.class);

And use it like
Logger.error(ex.getLocalisedMessage(),ex); 
Here ex refers to the Exception caught in try {} catch {} block 
And
Logger.info("This is just a plain info");

I will be grateful for your answer, if you can tell me how I can setup a 
separate logger in this case. 
My log4j.xml looks like this

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> 
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/";>
        <appender name="FileLogger" 
class="org.apache.log4j.RollingFileAppender">
                <param name="Threshold" value="INFO"/>
                <param name="File" value="ServerTool.log"/>
                <param name="Append" value="false"/>
                <layout class="org.apache.log4j.PatternLayout">
                        <param name="ConversionPattern" value="%d %-5p [%c] 
%m%n"/>
                </layout>       
        </appender>
        <appender name="EventLogger" 
class="org.apache.log4j.nt.NTEventLogAppender">
                <param name="Source" value="ICServerTool"/>
                <layout class="org.apache.log4j.PatternLayout">
                        <param name="ConversionPattern" value="%-5p [%t]: 
%m%n"/>
                </layout>
        </appender>
  
        <category name="org.apache.log4j.xml">
                <priority value="INFO"/>
        </category>
        <category name="com.nec.infocage" additivity="false">
                <priority value="DEBUG" />
                <appender-ref ref="EventLogger"/>
                <appender-ref ref="FileLogger"/>
        </category>
        <category name="org.hibernate" additivity="false">
                <priority value="error"/>
                <appender-ref ref="EventLogger"/>
                <appender-ref ref="FileLogger"/>
        </category>
</log4j:configuration>


Thanks and Best Regards,
Amit Pathak


-----Original Message-----
From: Javier Gonzalez [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 22, 2006 6:21 PM
To: Log4J Users List
Subject: Re: Disable logging for certain exceptions

You could try setting up a separate logger for the exceptions that
shouldn't go to the event log. Then disable additivity in that logger,
and attach only the file appender to it. That way, exceptions logged
through that logger will only go to the file and not the event log.

On 9/21/06, Amit Pathak <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am new to log4j, We are using it for logging our project's exceptions
> to File and Event log. Currently all the exceptions that are logged,
> goes to both file as well as Event Log, and we would like to append all
> of them to the file only. Certain exceptions should not goto the Event
> Log. Can anybody help in this regards.
>
>
>
> Thanks and Best Regards,
>
> Amit Pathak
>
>
>


-- 
Javier González Nicolini

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to