You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Abhilash_Pulakkudiyil <Ab...@satyam.com> on 2008/04/23 07:34:59 UTC

SMTP on log4j

Hi,

 

Am using the following configuration in the log4j.xml file to send email
on INFO. My Server is Weblogic 8.1. 

 

It is not working and my surprise it is not saying any error too. Can
anybody help on this.  

 

                <appender name="SS"
class="org.apache.log4j.net.SMTPAppender">

                                <param name="BufferSize" value="1" />

                                <param name="Threshold" value="INFO"/>

                                <param name="SMTPHost" value="VALID IP "
/>

                                <param name="From" value=" VALID EMAIL
ID " />

                                <param name="To" value="VALID EMAIL ID "
/>

                                <param name="Subject" value="Log4j
Application message" />

                        <layout class="org.apache.log4j.PatternLayout">

                           <param name="ConversionPattern" value="%p
%d{HH:mm:ss} %c (%F:%L) - %m%n"/>

                        </layout>

                </appender>

 

                <category name="SS">

                                <priority value="INFO" />

                                <appender-ref ref="SS" />

                </category>

 

Smtp.jar, mailapi.jar, activation.jar and mail.jar are there in the
classpath.

 

Also I tried the following also with the above configuration. But
everything is failed.

 

<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">

                                <appender-ref ref="SS"/>

                </appender>

                

                <root>        

                                <level value="INFO" />        

                                <appender-ref ref="STDOUT"/>        

                                <appender-ref ref="STDERR"/>   

                                <appender-ref ref="SS" />

                </root>

 

What's wrong here? Do I require any additional configuration for this?
Please provide me the complete configuration for the same.

 

Regards,

Abhilash P.



DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.

Re: SMTP on log4j

Posted by Curt Arnold <ca...@apache.org>.
On Apr 23, 2008, at 12:34 AM, Abhilash_Pulakkudiyil wrote:

> Hi,
>
>
>
> Am using the following configuration in the log4j.xml file to send  
> email
> on INFO. My Server is Weblogic 8.1.
>
>
>
> It is not working and my surprise it is not saying any error too. Can
> anybody help on this.
>

I think it is likely it is working as documented, but you are not  
encountering any ERROR or higher log requests that would actually  
trigger sending the emails.  The threshold level only sets what level  
is necessary for messages to go into the body of the message.  The  
buffer size controls the number of messages at the threshold level or  
higher that go into the body of the email, the triggering event  
evaluator determines when the message is set and the default  
triggering policy only sends when the level is ERROR or higher.  With  
a buffer size of one, any threshold level lower than ERROR is  
meaningless.

You can specify a triggering policy which implements  
org.apache.log4j.spi.TriggeringEventEvaluator using:

   <appender name="A1" class="org.apache.log4j.net.SMTPAppender">
...
     <param name="evaluatorClass" value="com.example.MyEvaluatorClass"/>
   </appender>


log4j 1.2.15 added the ability to add nested "triggeringPolicy"  
elements (http://issues.apache.org/bugzilla/show_bug.cgi?id=32572)  
which can be used with the  FilterBasedTriggeringPolicy from the  
extras companion (http://logging.apache.org/log4j/companions/extras)  
to specify a lower triggering level:

   <appender name="A1" class="org.apache.log4j.net.SMTPAppender">
   ...
     <triggeringPolicy  
class="org.apache.log4j.rolling.FilterBasedTriggeringPolicy">
		<filter class="org.apache.log4j.filter.LevelRangeFilter">
                   <param name="levelMin" value="info" />
		</filter>
     </triggeringPolicy>
    ...
    </appender>


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