Component space trace not working while Splitting serilog files

Hi
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 is not getting logged .

Please refer the attached serilog configuration which i have .

I have also followed the below link to enable trace , 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 is not working .
https://www.componentspace.com/Forums/7936/Enabling-SAML-Trace?Keywords=serilog


Can anyone help me resolve this issue ?

Could you elaborate on what’s not working?

I used the exact same Serilog configuration and ComponentSpace Information and Debug entries were written to the log file in the logs\WebApp\Informations folder.

I’ve copied your config below for reference.


“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”
}
},



I included the following Serilog package references.











The information log included entries such as:


2021-09-16T11:34:15.9726192+10:00 [INF] (ComponentSpace.Saml2.SamlProvider) ComponentSpace.Saml2, Version=3.7.0.0, Culture=neutral, PublicKeyToken=16647a1283418145, .NET 5.0 build, Licensed.
2021-09-16T11:34:15.9732505+10:00 [INF] (ComponentSpace.Saml2.SamlProvider) CLR: .NET 5.0.10, OS: Microsoft Windows 10.0.19043, Culture: English (Australia)
2021-09-16T11:34:15.9734046+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Configuration resolver: ComponentSpace.Saml2.Configuration.Resolver.SamlConfigurationResolver
2021-09-16T11:34:15.9739768+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Certificate manager: ComponentSpace.Saml2.Certificates.CertificateManager
2021-09-16T11:34:15.9740766+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Certificate loader: ComponentSpace.Saml2.Certificates.CachedCertificateLoader
2021-09-16T11:34:15.9741469+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) ID cache: ComponentSpace.Saml2.Cache.DistributedIDCache
2021-09-16T11:34:15.9742400+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Artifact cache: ComponentSpace.Saml2.Cache.DistributedArtifactCache
2021-09-16T11:34:15.9743180+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) SSO session store: ComponentSpace.Saml2.Session.DistributedSsoSessionStore


[quote]
ComponentSpace - 9/15/2021
Could you elaborate on what's not working?

I used the exact same Serilog configuration and ComponentSpace Information and Debug entries were written to the log file in the logs\WebApp\Informations folder.

I've copied your config below for reference.


"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"
}
},



I included the following Serilog package references.











The information log included entries such as:


2021-09-16T11:34:15.9726192+10:00 [INF] (ComponentSpace.Saml2.SamlProvider) ComponentSpace.Saml2, Version=3.7.0.0, Culture=neutral, PublicKeyToken=16647a1283418145, .NET 5.0 build, Licensed.
2021-09-16T11:34:15.9732505+10:00 [INF] (ComponentSpace.Saml2.SamlProvider) CLR: .NET 5.0.10, OS: Microsoft Windows 10.0.19043, Culture: English (Australia)
2021-09-16T11:34:15.9734046+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Configuration resolver: ComponentSpace.Saml2.Configuration.Resolver.SamlConfigurationResolver
2021-09-16T11:34:15.9739768+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Certificate manager: ComponentSpace.Saml2.Certificates.CertificateManager
2021-09-16T11:34:15.9740766+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Certificate loader: ComponentSpace.Saml2.Certificates.CachedCertificateLoader
2021-09-16T11:34:15.9741469+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) ID cache: ComponentSpace.Saml2.Cache.DistributedIDCache
2021-09-16T11:34:15.9742400+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Artifact cache: ComponentSpace.Saml2.Cache.DistributedArtifactCache
2021-09-16T11:34:15.9743180+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) SSO session store: ComponentSpace.Saml2.Session.DistributedSsoSessionStore


[/quote]
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.
Wil that be a problem ?

No. That shouldn’t be a problem.

[quote]
ComponentSpace - 9/15/2021
Could you elaborate on what's not working?

I used the exact same Serilog configuration and ComponentSpace Information and Debug entries were written to the log file in the logs\WebApp\Informations folder.

I've copied your config below for reference.


"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"
}
},



I included the following Serilog package references.











The information log included entries such as:


2021-09-16T11:34:15.9726192+10:00 [INF] (ComponentSpace.Saml2.SamlProvider) ComponentSpace.Saml2, Version=3.7.0.0, Culture=neutral, PublicKeyToken=16647a1283418145, .NET 5.0 build, Licensed.
2021-09-16T11:34:15.9732505+10:00 [INF] (ComponentSpace.Saml2.SamlProvider) CLR: .NET 5.0.10, OS: Microsoft Windows 10.0.19043, Culture: English (Australia)
2021-09-16T11:34:15.9734046+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Configuration resolver: ComponentSpace.Saml2.Configuration.Resolver.SamlConfigurationResolver
2021-09-16T11:34:15.9739768+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Certificate manager: ComponentSpace.Saml2.Certificates.CertificateManager
2021-09-16T11:34:15.9740766+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Certificate loader: ComponentSpace.Saml2.Certificates.CachedCertificateLoader
2021-09-16T11:34:15.9741469+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) ID cache: ComponentSpace.Saml2.Cache.DistributedIDCache
2021-09-16T11:34:15.9742400+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) Artifact cache: ComponentSpace.Saml2.Cache.DistributedArtifactCache
2021-09-16T11:34:15.9743180+10:00 [DBG] (ComponentSpace.Saml2.SamlProvider) SSO session store: ComponentSpace.Saml2.Session.DistributedSsoSessionStore


[/quote]
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.
Wil that be a problem ?[/quote]
In that case, am getting all other trace except component logs. What am i missing

Please try the following.

Modify the ExampleServiceProvider project’s appsettings.json with your Serilog configuration as shown above.

Add the package references as shown above.

Take a look at the information log.

I followed these steps and the logging worked.

If there’s still an issue, I suggest you zip up the modified ExampleServiceProvider project, without the binaries, and send it to support@componentspace.com so we can rebuild the project and reproduce the issue.

If the logging works with the modified ExampleServiceProvider, as it should, compare it with your application to see what’s different regarding the Serilog setup.