Due to some technical reasons we have separated logs and errors files into two individual files using serilog . In this case , logs and errors from component space trace alone is not getting logged
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Default": "Debug",
"Microsoft": "Information",
"Microsoft.Hosting.Lifetime": "Information",
"ComponentSpace": "Debug"
}
},
"WriteTo": [
{
"Name": "Logger",
"Args": {
"configureLogger": {
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": {
"expression": "(@l in ['Error', 'Fatal', 'Warning'])"
}
}
],
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/WebApp/Errors/error_.log",
"outputTemplate": "{Timestamp:o} [{Level:u3}] ({SourceContext}) {Message}{NewLine}{Exception}",
"rollingInterval": "Day"
}
}
]
}
}
},
{
"Name": "Logger",
"Args": {
"configureLogger": {
"Filter": [
{
"Name": "ByIncludingOnly",
"Args": {
"expression": "(@l in ['Information', 'Debug'])"
}
}
],
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/WebApp/Informations/log_.log",
"outputTemplate": "{Timestamp:o} [{Level:u3}] ({SourceContext}) {Message}{NewLine}{Exception}",
"rollingInterval": "Day"
}
}
]
}
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName"
],
"Properties": {
"Application": "MultipleLogFilesSample"
}
},
Please refer the below serilog configuration which am using
I have also followed the below link to enable trace , https://www.componentspace.com/Forums/7936/Enabling-SAML-Trace?Keywords=serilog which works good when i had the same configuration with name as "Serilog:Async" , but my problem is i have split the individual logger for log and error using the name "Logger", so in this case component space trace is not working .
Note: Hi thanks for replying , am not having these configurations on appsettings.json file instead am having these in a custom json file and the path of that custom json file is added in the appsettings.json file
Below code snippet is used for loading the log configuration from custon file
var configuration = new ConfigurationBuilder().SetBasePath(KestrelServerOptionsExtensions.GetBasePath()).AddJsonFile("appsettings.json").Build();
string ConfigPath = configuration.GetSection("AppSettings:ProlaborateConfigPath").Value;//ConfigPath
var Logconfiguration = new ConfigurationBuilder().AddJsonFile(ConfigPath).Build();
var functionDependencyContext = DependencyContext.Load(typeof(Startup).Assembly);
Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(Logconfiguration, "WebApp:Logger", dependencyContext: functionDependencyContext).CreateLogger();
Can anyone help me resolve this issue ?