Currently i have a web services project, in the startup code I have created a logger from Serilog like so:
public Startup()
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.File(AppDomain.CurrentDomain.BaseDirectory + "\\logs\\logs--"+ string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now) + ".log", outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}",shared:true)
.CreateLogger();
}
When the web application closes, the a log file will be created locally in the project domain folder. I would like to upload this file using Azure Blob Storage. My problem is that, I have no way of no knowing when the application will shut down for whatever reason, lets say an error or if the developer is done using it. I would like to upload all the logs from their session to a blob. IS there an area in web service code where it will go to before it closes so I can put the upload there?
THank you!
*** Edit ****
I added a method in the Global File:
protected void Application_End()
{
Log.Debug("We made it to application end");
Log.CloseAndFlush();
}