I'm using Serilog to log Errors in my WebApi with the following configuration.
private static readonly string LogFileName = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Logs/Service.log");
private static void ConfigureLogging(ContainerBuilder builder)
{
var loggerConfig = new LoggerConfiguration()
.ReadFrom.AppSettings()
.WriteTo.Console()
.WriteTo.File(LogFileName != null ? LogFileName : "C:/Temp/Logs/Service.log",
shared: true,
rollingInterval: RollingInterval.Day);
// configure global logger for logging in owin middleware
Log.Logger = loggerConfig.CreateLogger();
builder.Register(_ => Log.Logger).As<ILogger>(); }`
With Appsettings
<appSettings>
<add key="serilog:minimum-level" value="Warning" />
</appSettings>
The problem is, it only logs once. The Service is still alive, I can send more Successful requests. And I also see the requests/errors logged in console. But it doesnt add up in logfile.
BUT if I edit the WebConfig - change from Warning to Verbose then back to Warning, so no real changes - it logs again.
For Debugging and diagnostic use this selflog which might show you the extact error or problem your application is facing. Check this here https://github.com/serilog/serilog/wiki/Debugging-and-Diagnostics
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.