Can we assume that you've added the following to your
app.config file before the log4net section:

<configSections>
  <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,
log4net" />
</configSections>

Barry



--- "Rutledge, J. Mike" <[EMAIL PROTECTED]> wrote:
> 
> I've been trying my best to find code samples for
> using several of the appenders so I wouldn't bother
> you good folks. So far I've
> had no luck. I can find the config file entries but
> nothing else.
> 
> Here is what I'd like to do:
> 
> Use the SMTPAppender and SmtpPickupDirAppender. I
> can't get either to work.
> I assume that in the code you don't have to tell it
> what appender it is using (it's specified in the
> config file).
> 
> Also, is there a way to trap errors in the logger
> itself? With these appenders in the config file, it
> prevents the fileappender from
> working. Fileappender works when I remove the
> SmtpPickupDirAppender references.
> 
> Any help would be appreciated. This is such a cool
> tool. If I could get the email portion to work, that
> and the fileappender would
> cover 98% of what I do.
> 
> Thanks,
> Rut
> 
> 
> configfile
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <log4net>
> 
> <appender name="MyFirstFileAppender"
>       type="log4net.Appender.FileAppender">
>       <file value="c:\\testfile.txt" />
>       <appendToFile value="true" />
>       <layout type="log4net.Layout.PatternLayout">
>               <conversionPattern value="%5p %d (%c:%L) - %m%n"
> />
>       </layout>
> </appender>
> 
> <appender name="SMTPAppender"
> type="log4net.Appender.SMTPAppender">
>             <BufferSize value="1" />
>             <param name="To"
> value="[EMAIL PROTECTED]" />
>             <param name="From"
> value="[EMAIL PROTECTED]" />
>             <Subject value="log4net Error Message"
> />
>             <SMTPHost value="mail.rjr.com" />
>             <param name="LocationInfo" value="false"
> />
>             <param name="BufferSize" value="512" />
>             <param name="Lossy" value="true" />
>             <evaluator
> type="log4net.spi.LevelEvaluator">
>                 <param name="Threshold" value="ALL"
> />
>             </evaluator>
>             <layout
> type="log4net.Layout.PatternLayout">
>                 <param name="ConversionPattern"
> value="%n%d [%t] %-5p %c [%x] - %m%n%n%n" />
>             </layout>
> </appender>
> 
> <appender name="SmtpPickupDirAppender"
> type="log4net.Appender.SmtpPickupDirAppender">
>       <to value="[EMAIL PROTECTED]" />
>       <from value="[EMAIL PROTECTED]" />
>       <subject value="test logging message" />
>       <pickupDir value="C:\\SmtpPickup" />
>       <bufferSize value="512" />
>       <lossy value="true" />
>       <evaluator type="log4net.Core.LevelEvaluator">
>               <threshold value="ALL"/>
>       </evaluator>
>       <layout type="log4net.Layout.PatternLayout">
>               <conversionPattern value="%newline%date [%thread]
> %-5level %logger [%ndc] - %
> message%newline%newline%newline" />
>       </layout>
> </appender>
> 
> 
> <root>
>       <level value="ALL" />
>       <appender-ref ref="MyFirstFileAppender" />
>       <appender-ref ref="SMTPAppender" />
>       <appender-ref ref="SmtpPickupDirAppender />
> </root>
> 
> </log4net>
> 
> 
> 
> 
> c# code
> 
> string log4netConfigFilePath = Path.Combine
>
(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
>                               "log4net.config");
> 
>               
> log4net.Config.DOMConfigurator.ConfigureAndWatch(new
>                               FileInfo(log4netConfigFilePath));
> 
>                       log4net.Config.DOMConfigurator.Configure();             
>         
>                       log4net.ILog log  =
> log4net.LogManager.GetLogger(typeof(Form1));
>                               
>                       try
>                       {
>                               log.Info("NEW");
>                               log.Info("Another");
>                       }
>                       catch
>                       {
>                               MessageBox.Show("here");
>                       }
> 

There are only 10 types of people in the world - Those who understand binary, 
and those who don't.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to