I am using log4net with an ElasticsearchAppender. Now I would like to add another appender of ElasticSearch but with another index. What I did for now is:
<appender name="ElasticSearchAppender" type="log4net.ElasticSearch.ElasticSearchAppender, log4net.ElasticSearch">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%date - %level - %message %property{label} %property{mstimeload} %property{applicationid} %property{page}
%property{ipclient} %property{browser} %property{browsersignature} %property{appversion} %property{sessionuniquecodetag} %property{globalcountertailsloaded}
%property{ipserveraddress}" />
</layout>
<connectionString value="Server=myip;Index=log;Port=9200;rolling=true"/>
<lossy value="true" />
<bufferSize value="100" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="INFO"/>
</evaluator>
</appender>
<appender name="ElasticSearchAppenderClient" type="log4net.ElasticSearch.ElasticSearchAppender, log4net.ElasticSearch">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%date - %level - %message %property{label} %property{applicationid} %property{ipclient} %property{browser} %property{browserversione} %property{browsersignature}"/>
</layout>
<connectionString value="Server=myip;Index=logclient;Port=9200;rolling=true"/>
<lossy value="true" />
<bufferSize value="100" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="INFO"/>
</evaluator>
</appender>
Then on the server side I have
private static readonly log4net.ILog log = log4net.LogManager.GetLogger("ElasticSearchAppender");
private static readonly log4net.ILog logclient = log4net.LogManager.GetLogger("ElasticSearchAppenderClient");
The problem is when I add the values of the properties. because what I do is for example:
log4net.ThreadContext.Properties["label"] = label;
log4net.ThreadContext.Properties["ipclient"] = ipclient;
log4net.ThreadContext.Properties["applicationid"] = applicationid;
log4net.ThreadContext.Properties["page"] = page;
...
log.Info(ex);
for the first log and
log4net.ThreadContext.Properties["label"] = label;
log4net.ThreadContext.Properties["browser"] = browser;
log4net.ThreadContext.Properties["browserversion"] = browserversion;
...
logclient.Info("");
But then in the log with index logclient
I find the properties of the index log
and viceversa. I would like instead to have two different and separate log indexes with different properties for each index.