Replies: 4 comments
-
Hi @Orgbrat - just following up on the Gitter thread, it looks possible that you're calling: Log.Error("Message", ex); Instead of: Log.Error(ex, "Message"); Is that the cause? Cheers! |
Beta Was this translation helpful? Give feedback.
-
I wish that was the issue but I am using the Serilog.Extensions.Logging with the builtin ASP.NET core logging provider and DI which I believe uses the format _logger.LogError("Message", ex) format and should pass thru the pipeline using the Microsoft ILoggerFactory with _loggerFactory.AddSerilog() adding Serilog to the pipeline middleware. The format you have above is the standard Serilog format which is not used in ASP.NET Core unless you are skipping the middleware pipeline all together. Using this Serilog.Extensions.Logging. Now I am new to Serilog and I maybe I am all wrong... :) Steve |
Beta Was this translation helpful? Give feedback.
-
Serilog.Exceptions just adds more data to the log message but does not stop anything from getting logged. When you remove Serilog.Exceptions, does the exception data appear? If so, then it's us doign something wrong, otherwise its the other sinks you are using. |
Beta Was this translation helpful? Give feedback.
-
@RehanSaeed @nblumhardt Want to say thanks for all the help @nblumhardt was exactly right about which function call you need to use to send exception thru the pipeline and to Serilog. You must use at least _logger.LogError(1000, ex, "My Error") reference the Logger Extensions Class |
Beta Was this translation helpful? Give feedback.
-
Was having an issue with Serilog.Extensions.Logging and Serilog.Sinks.MSSqlServerCore in ASP.NET Core 1.1 writing to database, it created the logs table with no issue but would not write data. Finally got SerilogSelfLog working and was able to determine that the issue was the exception value was always null even though I know I am passing an exception object in the logger.LogError(“my error”, ex). Fixed the database column by allowing nulls and now I get data in table but the Exception column never gets any values. Looks like same issue within the rollingFile output (EX: 2017-05-15 08:06:52.471 -05:00 [Error] my error ). All the logging seems to be working as it writes all data including the message passed in with the exception but does not write the exception or exception details anywhere although the Error line or data row in database is written with all data less the exception. So I added Serilog.Exceptions to my ASP.NET Core 1.1 I have Serilog setup as below.
Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .Enrich.WithExceptionDetails() .MinimumLevel.Debug() .WriteTo.RollingFile(Path.Combine(env.ContentRootPath, "Logs/log-{Date}.txt"), retainedFileCountLimit: 7) .WriteTo.MSSqlServer(Configuration["Serilog:ConnectionString"], Configuration["Serilog:TableName"], autoCreateSqlTable: true) .CreateLogger();
Although logging seems to be working perfectly, I am still not seeing any exception or exception details logged in either the RollingFile log file or the MSSQL Server database exception column. I have confirmed the exception is not null as it is passed into the logger.LogError() function but somewhere it becomes a null object. Not sure where this issue is happening but need some help determining what is actually happening. Thanks...
Beta Was this translation helpful? Give feedback.
All reactions