SecondController
public class SecondController : Controller
{
private readonly ILogger _logger;
public SecondController(ILogger<SecondController> logger)
{
_logger = logger;
_logger.LogInformation("This is Second COntroller ");
}
public IActionResult Index()
{
_logger.LogInformation("This is Second COntroller Index");
return View();
}
}
Program.cs
public static void Main(string args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
Startup
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.MinimumLevel.Information()
.WriteTo.Http(requestUri: "http://localhost:8080", queueLimitBytes: null)
.CreateLogger();
FirstController
private readonly ILogger _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
_logger.LogInformation("This is Home COntroller Webapp");
}
public IActionResult Index()
{
_logger.LogInformation("This is Home COntroller Index");
return View();
}
appsetting
"Serilog": {
"MinimumLevel": "Info",
"WriteTo": [
{
"Name": "Http",
"Args": {
"requestUri": "http://localhost:8080",
"queueLimitBytes": null
}
}
]
},