You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies, for raising an issue... this is just a question:
I want to implement logging, using Serilog in my ASp.Net MVC Framework application. Please not that it is not a core application, so LoggerFactory is not automatically being injected into the program.
This is the tutorial explaining how everythign is done in ASP.Net MVC Core:
Add the following lines to the constructor of your Startup class
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.RollingFile(Path.Combine(env.ContentRootPath, "log-{Date}.txt"))
.CreateLogger();
Add the following line to the configure method of your Startup class
loggerFactory.AddSerilog();
Inject the logger to your services or controllers
public class Chat : IChat
{
// Instancia del logger
ILogger logger;
// Injectamos el logger en el constructor
public Chat(ILogger logger)
{
this.logger = logger;
}
Now this explanation is for .Net Core, I don't know how I should implement it in my MVC project...
I don't know how to Inject the LoggerFacory in my startup class... I can initialize it in my Startup and Add Serilog to it, but then how can I inject the Logger into my Constructor?
The text was updated successfully, but these errors were encountered:
Apologies, for raising an issue... this is just a question:
I want to implement logging, using Serilog in my ASp.Net MVC Framework application. Please not that it is not a core application, so LoggerFactory is not automatically being injected into the program.
This is the tutorial explaining how everythign is done in ASP.Net MVC Core:
"Serilog": "2.2.0",
"Serilog.Extensions.Logging": "1.2.0",
"Serilog.Sinks.RollingFile": "2.0.0",
"Serilog.Sinks.File": "3.0.0"
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.RollingFile(Path.Combine(env.ContentRootPath, "log-{Date}.txt"))
.CreateLogger();
loggerFactory.AddSerilog();
public class Chat : IChat
{
// Instancia del logger
ILogger logger;
Now this explanation is for .Net Core, I don't know how I should implement it in my MVC project...
I don't know how to Inject the LoggerFacory in my startup class... I can initialize it in my Startup and Add Serilog to it, but then how can I inject the Logger into my Constructor?
The text was updated successfully, but these errors were encountered: