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 Jonathan Rosenberg <jr...@tabbysplace.org> on 2012/01/28 21:27:32 UTC

SMTPAppender Problems

I am trying to set up logging via email.  Here is the relevant parts
of my log4j.xml

	<appender name='severe' class='org.apache.log4j.net.SMTPAppender'>
		<param name='SMTPDebug' value='true' />
    	<param name='To' value='XXXX@tabbysplace.org' />
    	<param name='From' value='XXXX@tabbysplace.org' />
    	<param name='SMTPHost' value='tabbysplace.org' />
    	<param name='SMTPPort' value='25' />
     	<param name='SMTPUsername' value='XXXX@tabbysplace.org' />
    	<param name='SMTPPassword' value=',XXXXXX' />
    	<param name='Subject' value='CAS Sever Error' />
    	<param name='bufferSize' value='1' />
    	<layout class='org.apache.log4j.PatternLayout'>
    		<param name="ConversionPattern" value='%d{[ dd.MM.yyyy
HH:mm:ss.SSS]} [%t] %n%-5p %n%c %n%C %n %x %n %m%n' />
    	</layout>
 		<filter class="org.apache.log4j.varia.LevelRangeFilter">
    		<param name="LevelMin" value="error" />
    		<param name="LevelMax" value="fatal" />
  		</filter>
 	</appender>
    <logger name='org.tabbysplace.sso' additivity='true'>
    	<level value='FATAL' />
    	<appender-ref ref='severe' />
    </logger>
    <logger name='org.tabbysplace.sso' additivity='true'>
    	<level value='INFO' />
    	<appender-ref ref='cas' />
    </logger>

Things were not working so I added the debugging flag.  I ran a bunch
of tests.  I see the console output, but except for 1 case (out of
dozens), there was no SMTP activity.

I then timed adding my own EvaluatorClass to see what was going on:

		<param name='EvaluatorClass' value='org.tabbysplace.casServer.Evaluator' />

This class writes to the console and tehn returns true.  The class is
never called.  It's as if the SMTPappender is heing ignored.

Any ideas?

--
Jonathan Rosenberg
Founder & Executive Director
Tabby's Place, a Cat Sanctuary
http://www.tabbysplace.org/

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


Re: SMTPAppender Problems

Posted by Jonathan Rosenberg <jr...@tabbysplace.org>.
Thanks for the ideas.  The problem was, indeed, having the logger defined twice.

--
Jonathan Rosenberg
Founder & Executive Director
Tabby's Place, a Cat Sanctuary
http://www.tabbysplace.org/


On Mon, Jan 30, 2012 at 12:26 AM, Jacob Kjome <ho...@visi.com> wrote:
>
> I suggest you run with log4j debugging, which you can set in the config file
> or using -Dlog4j.debug=true on the command line.
>
> Also, it seems odd to define two <logger/> entries with the same name
> "org.tabbysplace.sso".  I'm not sure what Log4j will do with this?  I can
> see the appenders being additive, so that both "cas" and "severe" appenders
> are defined for that logger, but since Level can only be one thing at a
> time, it's either going to be "INFO" or "FATAL".  I'm guessing it's FATAL
> and you aren't actually logging any fatal events (which should be rare),
> which would explain the lack of logging.
>
> Try defining the logger once and use a low level (like DEBUG or INFO) that
> you are absolutely sure will get triggered in your code.  Once you witness
> logging, then you can ramp up the Level so you aren't drowned in logging
> during normal usage of the app.
>
>
> Jake
>
>
> On Sat, 28 Jan 2012 15:27:32 -0500
>  Jonathan Rosenberg <jr...@tabbysplace.org> wrote:
>>
>> I am trying to set up logging via email.  Here is the relevant parts
>> of my log4j.xml
>>
>>        <appender name='severe' class='org.apache.log4j.net.SMTPAppender'>
>>                <param name='SMTPDebug' value='true' />
>>         <param name='To' value='XXXX@tabbysplace.org' />
>>         <param name='From' value='XXXX@tabbysplace.org' />
>>         <param name='SMTPHost' value='tabbysplace.org' />
>>         <param name='SMTPPort' value='25' />
>>         <param name='SMTPUsername' value='XXXX@tabbysplace.org' />
>>         <param name='SMTPPassword' value=',XXXXXX' />
>>         <param name='Subject' value='CAS Sever Error' />
>>         <param name='bufferSize' value='1' />
>>         <layout class='org.apache.log4j.PatternLayout'>
>>                 <param name="ConversionPattern" value='%d{[ dd.MM.yyyy
>> HH:mm:ss.SSS]} [%t] %n%-5p %n%c %n%C %n %x %n %m%n' />
>>         </layout>
>>                <filter class="org.apache.log4j.varia.LevelRangeFilter">
>>                 <param name="LevelMin" value="error" />
>>                 <param name="LevelMax" value="fatal" />
>>                 </filter>
>>        </appender>
>>     <logger name='org.tabbysplace.sso' additivity='true'>
>>         <level value='FATAL' />
>>         <appender-ref ref='severe' />
>>     </logger>
>>     <logger name='org.tabbysplace.sso' additivity='true'>
>>         <level value='INFO' />
>>         <appender-ref ref='cas' />
>>     </logger>
>>
>> Things were not working so I added the debugging flag.  I ran a bunch
>> of tests.  I see the console output, but except for 1 case (out of
>> dozens), there was no SMTP activity.
>>
>> I then timed adding my own EvaluatorClass to see what was going on:
>>
>>                <param name='EvaluatorClass'
>> value='org.tabbysplace.casServer.Evaluator' />
>>
>> This class writes to the console and tehn returns true.  The class is
>> never called.  It's as if the SMTPappender is heing ignored.
>>
>> Any ideas?
>>
>> --
>> Jonathan Rosenberg
>> Founder & Executive Director
>> Tabby's Place, a Cat Sanctuary
>> http://www.tabbysplace.org/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>

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


Re: SMTPAppender Problems

Posted by Jacob Kjome <ho...@visi.com>.
I suggest you run with log4j debugging, which you can set in the config file 
or using -Dlog4j.debug=true on the command line.

Also, it seems odd to define two <logger/> entries with the same name 
"org.tabbysplace.sso".  I'm not sure what Log4j will do with this?  I can see 
the appenders being additive, so that both "cas" and "severe" appenders are 
defined for that logger, but since Level can only be one thing at a time, it's 
either going to be "INFO" or "FATAL".  I'm guessing it's FATAL and you aren't 
actually logging any fatal events (which should be rare), which would explain 
the lack of logging.

Try defining the logger once and use a low level (like DEBUG or INFO) that you 
are absolutely sure will get triggered in your code.  Once you witness 
logging, then you can ramp up the Level so you aren't drowned in logging 
during normal usage of the app.


Jake

On Sat, 28 Jan 2012 15:27:32 -0500
 Jonathan Rosenberg <jr...@tabbysplace.org> wrote:
> I am trying to set up logging via email.  Here is the relevant parts
> of my log4j.xml
> 
> 	<appender name='severe' class='org.apache.log4j.net.SMTPAppender'>
> 		<param name='SMTPDebug' value='true' />
>    	<param name='To' value='XXXX@tabbysplace.org' />
>    	<param name='From' value='XXXX@tabbysplace.org' />
>    	<param name='SMTPHost' value='tabbysplace.org' />
>    	<param name='SMTPPort' value='25' />
>     	<param name='SMTPUsername' value='XXXX@tabbysplace.org' />
>    	<param name='SMTPPassword' value=',XXXXXX' />
>    	<param name='Subject' value='CAS Sever Error' />
>    	<param name='bufferSize' value='1' />
>    	<layout class='org.apache.log4j.PatternLayout'>
>    		<param name="ConversionPattern" value='%d{[ dd.MM.yyyy
> HH:mm:ss.SSS]} [%t] %n%-5p %n%c %n%C %n %x %n %m%n' />
>    	</layout>
> 		<filter class="org.apache.log4j.varia.LevelRangeFilter">
>    		<param name="LevelMin" value="error" />
>    		<param name="LevelMax" value="fatal" />
>  		</filter>
> 	</appender>
>    <logger name='org.tabbysplace.sso' additivity='true'>
>    	<level value='FATAL' />
>    	<appender-ref ref='severe' />
>    </logger>
>    <logger name='org.tabbysplace.sso' additivity='true'>
>    	<level value='INFO' />
>    	<appender-ref ref='cas' />
>    </logger>
> 
> Things were not working so I added the debugging flag.  I ran a bunch
> of tests.  I see the console output, but except for 1 case (out of
> dozens), there was no SMTP activity.
> 
> I then timed adding my own EvaluatorClass to see what was going on:
> 
> 		<param name='EvaluatorClass' value='org.tabbysplace.casServer.Evaluator' 
>/>
> 
> This class writes to the console and tehn returns true.  The class is
> never called.  It's as if the SMTPappender is heing ignored.
> 
> Any ideas?
> 
> --
> Jonathan Rosenberg
>Founder & Executive Director
> Tabby's Place, a Cat Sanctuary
> http://www.tabbysplace.org/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 


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