I have set an example of my code but I'm not able to logs in kibana with authentication using serilog. Here, I have attached my code please correct it.
Log.Logger = new LoggerConfiguration()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("myurl:9200"))
{
IndexFormat = "ChargeMasterlog-{yyyy.MM.dd}",
ModifyConnectionSettings = x => x.BasicAuthentication("username", "password"),
}).CreateLogger();
Log.Information("Hello, Serilog!");
Step1: Install this NuGet package "Serilog.Sinks.Elasticsearch"
Step2: Add this in App.config or Web.config
Step3: Add this in program.cs in main() OR Global.asax in Application_Start()
Step4: Log events where you want by adding
If you want to use with log4net then
Step1: Install this NuGet package "log4net.Elasticsearch"
Step2: Add this "[assembly: log4net.Config.XmlConfigurator(Watch = true)]" in AssemblyInfo.cs
Step3: Add these things in web.config
Step4: Log events where you want by adding