We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I try to send mail with serilog, but I have this error:
Unable to find a method called Email for supplied arguments: batchingOptions, emailSubject, enableSsl, fromEmail, mailServer, outputTemplate, password, port, restrictedToMinimumLevel, toEmail, username. Candidate methods are: Email(from, to, host, port, connectionSecurity, credentials, subject, body, formatProvider, restrictedToMinimumLevel, levelSwitch) Email(options, batchingOptions, restrictedToMinimumLevel, levelSwitch)
My appsettings.json is: { "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, "Serilog": { "Using": [ "Serilog.Sinks.Email" ], "MinimumLevel": { "Default": "Debug", "Override": { "Microsoft": "Warning" } }, "WriteTo": [ { "Name": "Email", "Args": { "fromEmail": "[email protected]", "toEmail": [ "[email protected]" ], "mailServer": "smtp.gmail.com", "port": 587, "enableSsl": true, "username": "[email protected]", "password": "password", "emailSubject": "Mail Error", "restrictedToMinimumLevel": "Debug", "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] ({SourceContext}) {NewLine}{Message}{NewLine}{Exception}" } }, { "Name": "File", "Args": { "path": "Logs/Error_.log", "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] ({SourceContext}) {NewLine}{Message}{NewLine}{Exception}{NewLine}{NewLine}", "rollingInterval": "Day", "retainedFileCountLimit": 10, "restrictedToMinimumLevel": "Debug" } }, { "Name": "Console", "Args": { "restrictedToMinimumLevel": "Debug", "OutputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {Message:lj}{NewLine}{Exception}" } } ] } }
and my Program.cs is:
`using Serilog;
var builder = WebApplication.CreateBuilder(args); Serilog.Debugging.SelfLog.Enable(Console.Out); Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(builder.Configuration) .CreateLogger();
builder.Host.UseSerilog(); builder.Services.AddControllers();
var app = builder.Build(); app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers();
app.Logger.LogDebug("Application started");
Log.Error("This is a test error to check email functionality");
app.Run();`
Thank you Andrea
The text was updated successfully, but these errors were encountered:
Perahps this will help .Net Core and Serilog Email sink - JSON Config
Sorry, something went wrong.
No branches or pull requests
Hi,
I try to send mail with serilog, but I have this error:
Unable to find a method called Email for supplied arguments: batchingOptions, emailSubject, enableSsl, fromEmail, mailServer, outputTemplate, password, port, restrictedToMinimumLevel, toEmail, username. Candidate methods are:
Email(from, to, host, port, connectionSecurity, credentials, subject, body, formatProvider, restrictedToMinimumLevel, levelSwitch)
Email(options, batchingOptions, restrictedToMinimumLevel, levelSwitch)
My appsettings.json is:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Serilog": {
"Using": [ "Serilog.Sinks.Email" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Warning"
}
},
"WriteTo": [
{
"Name": "Email",
"Args": {
"fromEmail": "[email protected]",
"toEmail": [ "[email protected]" ],
"mailServer": "smtp.gmail.com",
"port": 587,
"enableSsl": true,
"username": "[email protected]",
"password": "password",
"emailSubject": "Mail Error",
"restrictedToMinimumLevel": "Debug",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] ({SourceContext}) {NewLine}{Message}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "Logs/Error_.log",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] ({SourceContext}) {NewLine}{Message}{NewLine}{Exception}{NewLine}{NewLine}",
"rollingInterval": "Day",
"retainedFileCountLimit": 10,
"restrictedToMinimumLevel": "Debug"
}
},
{
"Name": "Console",
"Args": {
"restrictedToMinimumLevel": "Debug",
"OutputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
]
}
}
and my Program.cs is:
`using Serilog;
var builder = WebApplication.CreateBuilder(args);
Serilog.Debugging.SelfLog.Enable(Console.Out);
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(builder.Configuration)
.CreateLogger();
builder.Host.UseSerilog();
builder.Services.AddControllers();
var app = builder.Build();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Logger.LogDebug("Application started");
Log.Error("This is a test error to check email functionality");
app.Run();`
Thank you
Andrea
The text was updated successfully, but these errors were encountered: