logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Wyss" <Patrick.W...@mobilesolutions.ch>
Subject AW: Problem using SMTPAppender
Date Thu, 31 Aug 2006 12:33:23 GMT
1) i think you have to set TriggeringLevel. i m running with:
log4j.appender.EMAIL=org.apache.log4j.net.SMTPAppender
log4j.appender.EMAIL.layout=org.apache.log4j.PatternLayout
log4j.appender.EMAIL.layout.ConversionPattern=%d %-5p [%t] %c - %m%n
log4j.appender.EMAIL.threshold=DEBUG
log4j.appender.EMAIL.TriggeringLevel=WARN
#send the last xxx items if triggering level is reached:
log4j.appender.EMAIL.bufferSize=100
log4j.appender.EMAIL.to=sombody@whatever.som
log4j.appender.EMAIL.from=sombody@whatever.som
log4j.appender.EMAIL.subject=HELP!
log4j.appender.EMAIL.SMTPHost=somehost


2) just in case: are you sure you have a smtp running on you localhost?
i.e. can you do a:
telnet localhost 25

cheers
patrick

-----Ursprüngliche Nachricht-----
Von: Thomas Saxtoft [mailto:TS@sondagsavisen.dk]
Gesendet: Donnerstag, 31. August 2006 14:06
An: log4j-user@logging.apache.org
Betreff: Problem using SMTPAppender


I have been fiddling with SMPTAppender for a day now, so now I give up.

My problem is that when logging to SMTPAppender it does not send any e-mails. The logger I
use also logs to a file which works fine.
I have been using a TCP monitor to see if anything goes thru port 25, but it never gets a
connection.

In my program I log with priority "error", and my log4j.xml looks like the following. I use
localhost as SMTPHost in order to monitor the port 25. Can anyone see what I'm missing or
have done wrong?

<log4j:configuration>
  <appender name="MOBILE_APPENDER" class="org.apache.log4j.net.SMTPAppender">
    <param name="SMTPHost" value="localhost"/>
    <param name="To" value="to@mail.com"/>
    <param name="From" value="from@mail.com"/>
 <param name="BufferSize" value="1"/>
 <param name="Threshold" value="DEBUG"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p %c(%M:%L) - %m%n"/>
    </layout>
  </appender>

  <appender name="MOBILE_DEBUG" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="File" value="log/mobile_debug.log"/>
    <param name="DatePattern" value="'.'yyyy-MM-dd"/>
    <param name="Threshold" value="DEBUG"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %-5p %c{1}(%M:%L)
- %m%n"/>
    </layout>
  </appender>

  <logger name="mobileLogger">
    <level value="debug"/>
    <appender-ref ref="MOBILE_APPENDER"/>
    <appender-ref ref="MOBILE_DEBUG"/>
  </logger>
</log4j:configuration>

And a small java program:

public class TestSmptAppender {
  private static final Logger logger = Logger.getLogger("mobileLogger");
  public static void main(String[] args) {
    System.out.println("1");
    logger.error("2");
    System.out.println("3");
  }
}

Kind regards

Thomas Saxtoft
Java-developer

Gladsaxe Møllevej 28
2860 Søborg
Tlf.: 39 57 75 31 (direkte)
Fax: 39 57 75 97
t.saxtoft@sondagsavisen.dk

Besøg os på: www.sondagsavisen.dk



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


Mime
View raw message