I am using ASP.NET CORE 2.1 with NLog. I can log to email, files and the internal log without issue.
I would like to send an email once for an http request like a log for that request.
I read that this AspNetBufferingWrapper will work reference https://github.com/NLog/NLog/wiki/AspNetBufferingWrapper-target
Within my nlog.config I have the following target...the aspnetbuffer wrapping my working email target.
<target xsi:type="AspNetBufferingWrapper"
name="AspNetBufferingWrapper1"
bufferGrowLimit="Integer"
growBufferAsNeeded="Boolean"
bufferSize="Integer">
<target name="WrappedRulesEngineLogMail" xsi:type="Mail"
smtpServer="TEST.TEST.COM"
subject="Wrapped Rules Engine Log"
layout="[${longdate}] - [${machinename}] - [${level}] - [${message}] - [${exception:format=toString}]"
from="[email protected]"
to="[email protected]"/>
</target>
The internal log responds with this error message
nlog.config failed. Exception: NLog.NLogConfigurationException: Exception when parsing C:\inetpub\wwwroot\IT\TEST\ACES\Main\Aces.Web\bin\Debug\netcoreapp2.1\nlog.config. ---> System.ArgumentException: Target cannot be found: 'AspNetBufferingWrapper'. Is NLog.Web not included? at NLog.Config.Factory`2.CreateInstance(String name) at NLog.Config.XmlLoggingConfiguration.ParseTargetsElement(NLogXmlElement targetsElement) at NLog.Config.XmlLoggingConfiguration.ParseNLogElement(NLogXmlElement nlogElement, String filePath, Boolean autoReloadDefault) at NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader, String fileName, Boolean ignoreErrors)
For completeness I will include my setup within the Program.cs
public static IWebHost CreateDefaultBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging((context, logging) => {
logging.ClearProviders(); logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
if (context.HostingEnvironment.IsDevelopment())
{
logging.AddDebug();
}
})
.UseNLog() // NLog: setup NLog for Dependency injection
.Build();
I have these nuget packages loaded
I do not know how to resolve Target cannot be found: 'AspNetBufferingWrapper'. Is NLog.Web not included? at NLog.Config.Factory`2.CreateInstance(String name)
Why can target be found?
ty
growBufferAsNeeded="Boolean"
=>growBufferAsNeeded="true"
– pinkfloydx33NLog.Web.AspNetCore
: nuget.org/packages/NLog.Web.AspNetCore - it seems like your target and the missing assembly are defined there – pinkfloydx33