I have a simple c# prgram trying to log to elastic search 8.6, elasticsearch and kibana are up and running. i can send logs using curl and I can see my logs in kibana. I can't send logs using my c# app using log4net. there's no visible error but the logs are not in elastic search. Here is my code and configuration: log4net.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- Be sure this configSections block is immediately after the <configuration> opening tag! -->
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<log4net debug="true">
<appender name="Console" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="DEBUG" />
<levelMax value="FATAL" />
</filter>
</appender>
<appender name="ElasticSearchAppender" type="log4net.ElasticSearch.ElasticSearchAppender, log4net.ElasticSearch">
<connectionString value="Scheme=http;Server=localhost;Index=my-index-000001;Port=9200;User=user;Pwd=myPassword;rolling=true;" />
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="ElasticSearchAppender" />
<appender-ref ref="Console" />
</root>
</log4net>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
This is my c# code:
static void Main(string[] args)
{
// Load the log4net configuration
ILoggerRepository repository = LogManager.CreateRepository("MyApp");
// Load the log4net configuration
XmlConfigurator.Configure(repository, new FileInfo("log4net.config"));
// Get the logger for the current class
ILog log = LogManager.GetLogger(repository.Name, typeof(Program));
log.Logger.Repository.Threshold = Level.Info;
// Log some events
log.Info("Application started.");
log.Debug("Application started debugging.");
log.Warn("This is a warning message.");
log.Error("Oh my god.");
// Wait for user input
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
Any one knows how to get it working?