Visitar URL original
NLog.NLogConfigurationException: BufferingTargetWrapper(Name=mailbuffer): No wrapped Target configured. · Issue #6050 · NLog/NLog · GitHub
Skip to content

NLog.NLogConfigurationException: BufferingTargetWrapper(Name=mailbuffer): No wrapped Target configured. #6050

Closed

Description

@virtualdreams

Hi! Thanks for reporting this bug!

Please keep / fill in the relevant info from this template so that we can help you as best as possible.

NLog version: 6.0.6

Platform: .NET10/Windows

Current NLog config (xml or C#, if relevant)

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xsi:schemaLocation="NLog NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      internalLogLevel="Error"
      internalLogFile="logs\internal.log">

  <!-- the targets to write to -->
  <targets>
    <!-- write logs to file -->
    <target xsi:type="File" name="file" maxArchiveFiles="7" fileName="logs\newsticker-cli-${shortdate}.log" layout="${longdate} ${pad:padding=-5:inner=${uppercase:${level}}} ${message} ${exception}" />

    <!-- write logs to console -->
    <target xsi:type="Console" name="console" layout="${pad:padding=-5:inner=${uppercase:${level}}} ${message} ${exception}" />

    <!-- mail -->
    <target xsi:type="BufferingWrapper" name="mailbuffer" slidingTimeout="false" bufferSize="10000" flushTimeout="-1">
      <target xsi:type="Mail" name="mail" 
          smtpServer="example.org"
          smtpPort="25"
          enableSsl="true"
          smtpAuthentication="Basic"
          smtpUserName="username"
          smtpPassword="password"
          from="example@example.org"
          to="example@example.org"
          addNewLines="true"
          subject="newsticker-cli ${mdc:item=newsticker-verb} - ${longdate} - ${machinename}"
          layout="${longdate} ${pad:padding=-5:inner=${uppercase:${level}}} ${message} ${exception}"
        />
      </target>
  </targets>

  <!-- rules to map from logger name to target -->
  <rules>
    <logger name="*" minlevel="Info" writeTo="console, file, mailbuffer" />
  </rules>
</nlog>
  • What is the current result?

Emails are no longer being sent due to the error. Worked perfectly in 5.4.

  • What is the expected result?

Sending mails.

NLog.NLogConfigurationException: BufferingTargetWrapper(Name=mailbuffer): No wrapped Target configured.
  • Please post full exception details (message, stacktrace, inner exceptions)
  • Are there any workarounds? no, just downgrade
  • Is there a version in which it did work? 5.4
  • Can you help us by writing an unit test?

Activity

  1. snakefoot commented on Nov 24, 2025

    @snakefoot
    Contributor

    NLog v6 includes several major changes

    NLog v6 has reduced its footprint by extracting features into separate nuget-packages:

    I'm guessing that NLog doesn't recognize xsi:type="Mail", and you need to add NLog.Targets.Mail as dependency to your application.

  2. virtualdreams commented on Nov 25, 2025

    @virtualdreams
    Author

    Hi,

    thanks for pointing that out. I added the dependency to the project and sending emails is working again.

    I completely overlooked that part in the major changes because I was only focusing on the BufferingWrapper. Perhaps a note could be added to the log asking whether a dependency is missing?

  3. snakefoot commented on Nov 25, 2025

    @snakefoot
    Contributor
  4. virtualdreams commented on Nov 25, 2025

    @virtualdreams
    Author

    This is the complete log output in my “internal.log” file. I don't see anything with "mail". Only that the target is empty. But it isn't. :)

    2025-11-24 21:00:03.7597 Error BufferingWrapper(Name=mailbuffer): No output because target failed initialize. Exception: NLog.NLogConfigurationException: BufferingTargetWrapper(Name=mailbuffer): No wrapped Target configured.
       at NLog.Targets.Wrappers.WrapperTargetBase.InitializeTarget()
       at NLog.Targets.Wrappers.BufferingTargetWrapper.InitializeTarget()
       at NLog.Targets.Target.Initialize(LoggingConfiguration configuration)
    2025-11-24 21:00:50.8447 Error BufferingWrapper(Name=mailbuffer): WrappedTarget is NULL
    2025-11-24 21:00:50.8447 Error BufferingWrapper(Name=mailbuffer): WrappedTarget is NULL
    
  5. snakefoot commented on Nov 25, 2025

    @snakefoot
    Contributor

    Yes unable to resolve target-type should be an error, and not a warning as it is now:

    2025-11-25 18:39:14.2875 Warn Error has been raised. Exception: NLog.NLogConfigurationException: Failed to create Target with unknown type-alias: 'Mail' - Extension NLog.Targets.Mail not included?
       at NLog.Config.FactoryExtensions.CreateInstance[TBaseType](IFactory`1 factory, String typeAlias)
       at NLog.Config.LoggingConfigurationParser.FactoryCreateInstance[T](String typeName, IFactory`1 f
    

    Thank you for the feedback, and helping to improve the NLog-library.

  6. snakefoot commented on Nov 25, 2025

    @snakefoot
    Contributor

    Created #6051 to improve the InternalLogger output.

  7. added this to the 6.0.7 milestone on Nov 30, 2025
  8. snakefoot commented on Dec 9, 2025

    @snakefoot
    Contributor

    NLog v6.0.7 has been released that upgrades from warning to error when failing to create targets.

    Thank you again for the feedback, and helping to improve NLog.

  9. virtualdreams commented on Dec 9, 2025

    @virtualdreams
    Author

    Thanks, the content of the exception looks better now.

    2025-12-09 13:15:53.5400 Error Failed to create Target with unknown type-alias: 'Mail' - Extension NLog.Targets.Mail not included? Exception: NLog.NLogConfigurationException: Failed to create Target with unknown type-alias: 'Mail' - Extension NLog.Targets.Mail not included?
       at NLog.Config.FactoryExtensions.CreateInstance[TBaseType](IFactory`1 factory, String typeAlias)
       at NLog.Config.LoggingConfigurationParser.FactoryCreateInstance[T](String typeName, IFactory`1 factory)
    2025-12-09 13:15:53.9623 Error BufferingWrapper(Name=mailbuffer): No output because target failed initialize. Exception: NLog.NLogConfigurationException: BufferingTargetWrapper(Name=mailbuffer): No wrapped Target configured.
       at NLog.Targets.Wrappers.WrapperTargetBase.InitializeTarget()
       at NLog.Targets.Wrappers.BufferingTargetWrapper.InitializeTarget()
       at NLog.Targets.Target.Initialize(LoggingConfiguration configuration)
    2025-12-09 13:15:53.9838 Error BufferingWrapper(Name=mailbuffer): WrappedTarget is NULL
    2025-12-09 13:15:53.9838 Error BufferingWrapper(Name=mailbuffer): WrappedTarget is NULL
    
  10. snakefoot commented on Dec 10, 2025

    @snakefoot
    Contributor

    Thank you for the fast feedback. Happy the result has been improved.

    Not entirely sure why NLogConfigurationException was downgraded to Warn-level by default. But decided here #1143

    But if using ThrowConfigExceptions = true then NLogConfigurationException will be alerted at Error-level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions