I am currently trying to change our system configuration to work with Serilog (instead of working with FileBeat as a shipper to LogStash)
We are also working with the log type field (which is easy to configure in the FileBeat config file) in our various queries and for indexing out logs on Elastic.
The problem is that when using Serilog we get the default type logevent, and I didn't find where I can configure it. I want to have an option to determine a specific log type per Serilog instance. At the moment I have the default type for all of my logs.
my Serilop Config is:
var path = GetLogPath();
var logger = new LoggerConfiguration()
.MinimumLevel.Information()
.Enrich.WithMachineName()
.Enrich.WithProperty("RequestId", Guid.NewGuid())
.WriteTo.RollingFile(
pathFormat: path,
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u4}] [{RequestId}] {Message}{NewLine}{Exception}", buffered: false, shared: true);
logger.WriteTo.Elasticsearch(
new ElasticsearchSinkOptions(new Uri(this.configurationService.ElasticSearchUrl())));
How can I change the log type?
EDIT
After some investigation, I found out I suppose to change the typeName filed in the LoggerConfiguration and seem that I can do so only through the AppConfig file, which again event if I will change it, the change will affect all the logger instances.
Do I miss something?
typemeans to you. In general, in Serilog, there is a{SourceContext}property you can put in as a token into the emit format if you mean the type associated with the logger. if you mean an id for the message template, github.com/serilog/serilog-formatting-compact will give you clues. (I know zero about the ES sink (obviously) but if you emit json, you can normally use the format to guid what to include) - Ruben Bartelink