log4net - smtp

  • 13 years ago

    I have tried to config my log4net to send mail on all info. This is my xml:

     

    <?

    xml version="1.0" encoding="utf-8" ?>

    <

    configuration>

    <

    configSections>

    <

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

    </

    configSections>

    <

    log4net>

    <

    appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">

    <

    to value="mymail" />

    <

    from value="[email protected]" />

    <

    subject value="test logging message" />

    <

    smtpHost value="smtphost" />

    <

    Username value="username" />

    <

    Password value="password" />

    <

    bufferSize value="512" />

    <

    lossy value="false" />

    <

    evaluator type="log4net.Core.LevelEvaluator">

    <

    threshold value="INFO" />

    </

    evaluator>

    <

    layout type="log4net.Layout.PatternLayout,log4net">

    <

    conversionPattern value="%property{log4net:HostName} :: %level :: %message %newlineLogger: %logger%newlineThread: %thread%newlineDate: %date%newlineNDC: %property{NDC}%newline%newline" />

    </

    layout>

    </

    appender>

    </

    log4net>

    <

    appSettings>

    </

    appSettings>

    </configuration>

    It does not work. Any suggestion how to solve my problem?

  • 13 years ago
    Can you give us some more information, aside from "it does not work"? :) Are there any errors, or do the mails simply not arrive? Are you sure the sMTP details are correct?
  • 13 years ago

    System.TypeLoadException: Could not load type 'log4net.Core.LevelEvaluator'.

     

    This is my config now:

    <?

    xml version="1.0" encoding="utf-8" ?>

    <

    configuration>

    <

    configSections>

    <

    section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" />

    </

    configSections>

    <

    log4net>

    <

    root>

    <

    level value="ERROR"></level>

    <

    appender-ref ref="SmtpAppender"/>

    </

    root>

    <

    appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">

    <

    to value="mymail" />

    <

    from value="frommail" />

    <

    subject value="test logging message" />

    <

    smtpHost value="smtp" />

    <

    bufferSize value="512" />

    <

    lossy value="true" />

    <

    evaluator type="log4net.Core.LevelEvaluator">

    <

    threshold value="WARN"/>

    </

    evaluator>

    <

    layout type="log4net.Layout.PatternLayout">

    <

    conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />

    </

    layout>

    </

    appender>

    <

    logger name="log4nettestmail">

    <

    level value="ERROR"/>

    </

    logger>

    </

    log4net>

    </configuration>

  • 13 years ago
    Solved it! old version of log4net! :-/

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Better train people and risk they leave – than do nothing and risk they stay.” - Anonymous