I want to have my serilog to write to my MSSQL server only and not to the log viewer in backoffice.
I know umbraco 10 version comes with serilog already.
Therefore I tried to add the serilog configuration programatically.
But it seems like, its only working when I startup.
e.g:
in my program.cs Main I have the following code:
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.WriteTo
.MSSqlServer(
connectionString: "ConnectionString",
sinkOptions: new MSSqlServerSinkOptions { TableName = "TableName" })
.CreateLogger();
CreateHostBuilder(args).Build().Run();
}
And in my startup cs I have this line of code:
Log.Information("Hello from startupcs");
When I start my application, I get the line in my table:
But if I try and call Log.Information in a controller, the log will not write it to my database.
Any ideas, on how to set the global setting for my serilog, so it writes to my MSSQL server all the time?
Is it possible to change the settings for the added serilog already?
Make Serilog write to MSSQL server only
Hello everyone :)
I want to have my serilog to write to my MSSQL server only and not to the log viewer in backoffice. I know umbraco 10 version comes with serilog already.
Therefore I tried to add the serilog configuration programatically.
But it seems like, its only working when I startup. e.g: in my program.cs Main I have the following code:
And in my startup cs I have this line of code:
When I start my application, I get the line in my table:
But if I try and call Log.Information in a controller, the log will not write it to my database.
Any ideas, on how to set the global setting for my serilog, so it writes to my MSSQL server all the time?
Is it possible to change the settings for the added serilog already?
Thanks in advance!
is working on a reply...