Thanks Nicko, A little bit more thinking and I would have thought of that :p
The SimpleSMTPAppender will come in handy with FATAL level events. Regards Anthony -----Original Message----- From: Nicko Cadell [mailto:[EMAIL PROTECTED] Sent: Friday, 20 August 2004 04:42 To: Log4NET User Subject: RE: SMTPAppender Placing variables in Subject field Anthony, The SmtpAppender is designed to send several events in a single email. That makes it rather difficult to know which event to pull the subject from: first event, last event, event with highest level, what about multiple events at the highest level. etc... Currently we don't try to do anything clever and only allow a fixed message. If you need more control over the subject line you will need to write a custom appender. I have attached a simple appender that sends log events via email as soon as they arrive, one by one. This is just an example and may not be suitable for your requirements, sending an email synchronously for each log message may be a performance issue. It does allow you to use a PatternLayout to set the value of the subject line. To configure this appender you would use the following: <appender name="SimpleSmtpAppender" type="ConsoleTest.SimpleSmtpAppender,ConsoleTest"> <to value="[EMAIL PROTECTED]" /> <from value="[EMAIL PROTECTED]" /> <smtpHost value="SMTPServer.domain.com" /> <subject> <conversionPattern value="LOGMSG: [%c] %p" /> </subject> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%n%d [%t] %-5p %c [%x] - %m%n%n%n" /> </layout> </appender> Obviously you will need to update the type attribute on the <appender> to point to the assembly you write. Hope this is usefull, Nicko > -----Original Message----- > From: Borton, Anthony [mailto:[EMAIL PROTECTED] > Sent: 18 August 2004 06:09 > To: [email protected] > Subject: SMTPAppender Placing variables in Subject field > > > > I am trying to find a way to place the name of the logger and > the loglevel into the subject field of the email that is sent > using the SMTPAppender. > > Eg. Email subject = "ABC.Logger - INFO" > > I crossed my fingers and tried what I thought the obvious > solution might be but the following configuration does not > substitute the correct values for %l and %p. > > SAMPLE CONFIG > ---------------------- > <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender"> > <to value="[EMAIL PROTECTED]" /> > <from value="[EMAIL PROTECTED]" /> > <subject value="%l - %p" /> ' does not work > here > <smtpHost value="SMTPHost" /> > > Any ideas of the correct way to achieve this? > > Thanks > > ********************************************************************** > This email and any files transmitted with it are confidential > and intended solely for the use of the individual or entity > to whom they are addressed. If you have received this email > in error please notify the system manager of QR. > > This message has been scanned for the presence of computer > viruses. No warranty is given that this message upon its > receipt is virus free and no liability is accepted by the > sender in this respect. > > This email is a message only; does not constitute advice and > should not be relied upon as such. > ********************************************************************** > ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager of QR. This message has been scanned for the presence of computer viruses. No warranty is given that this message upon its receipt is virus free and no liability is accepted by the sender in this respect. This email is a message only; does not constitute advice and should not be relied upon as such. **********************************************************************
