Defining an SMTPAppender should be all that you need. But you must ensure that the SMTP info you provide leads to an SMTP server. Is there one running on your system (your config has 'localhost' as the SMTPHost)? When I tried this a while back I used the SMTP host provided by by ISP and that worked.
thanks for your fast response.
but still it doesnt work.
whats about the "from" field? Must this address: email@example.com be a valid address ?
do i have to define a category, like :
<category name="org.jboss.portal"> <priority value="ERROR" /> <appender-ref ref="SMTP" /> </category>
I have always used a valid "from" field, even the log4j book I have is silent as to if the "from" address needs to be valid.
You don't have to add the extra category - what you did earlier for root should be fine.
The one thing I don't see for the SMTPAppender is authentication handling. I know that my ISP requires an account and a password to send email. But I cannot recall how I handled this when I set up the SMTPAppender before (and of course I no longer have that configuration).
OK, I looked up the javadoc for SMTPAppender (http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SMTPAppender.html), there is a SMTPUsername and SMTPPassword parameter, which you can set using:
<appender ...> ... <param name="SMTPUsername" value="xxx"/> <param name="SMTPPassword" value="xxx"/> </appender>
The stupid book I have doesn't event mention these parameters, nor a few others that are available on SMTPAppender.