-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Structured variables not shown when Serilog used #169
Comments
Hi @VladoP, Good morning. Thanks for posting the issue. Could you please elaborate what variables you are referring to and provide some code sample to investigate the issue? Any logs would also be helpful. Are you referring to enrichers Preferred format for sharing above information: Expected BehaviorCurrent BehaviorPossible SolutionSteps to Reproduce (for bugs)ContextYour Environment
.NET Core Info
Thanks, |
This issue has not received a response in a week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled. |
I'm also seeing an issue with structured logging variables not showing up with the .Net Core API, so I don't think it's Serilog specific. I have the following configuration:
Here is my appSettings.json:
I'm logging the following structured log:
I would expect this to be sent as a structured log to CloudWatch, but it appears to send an interpolated string: Here, I would expect to see the variables: It appears the library doesn't preserve the message. I'm guessing this is what the OP was expressing, that when they use Serilog with Serilog's AWS sink that it correctly preserves the variables, but when using the "official" microsoft library for logging to CloudWatch with Serilog that it isn't preserving the variables. Seems like it's because the core library just doesn't properly support structured logging. |
This is a follow-up to my previous comment. My cloud experience to date has primarily been in Azure. Upon seeing AWS CloudWatch's interface, I presumed it was facilitating discrete custom fields the way Azure AppInsights does. Using Microsoft's AppInsights logging provider, it takes the structured logging data and maps it to the custom properties for the log entry. After learning a bit more about CloudWatch, I'm now thinking that it doesn't quite work that way. It seems it has the notion of standard fields and "discovered" fields, but it it doesn't seem to deal with custom fields in quite the same way as AppInsights. If this is indeed the way it works, it would seem that the CloudWatch provider really has no other recourse but to use.Net Core's structured logging data for string interpolation, in which case it isn't a bug in this library so much as just a limitation of CloudWatch. |
Needs review with team to investigate structured logging and how it could be supported by AWS logging libraries. |
This is really a problem because if we need to push message to Standard Log-group then we are doomed. We are using Serilog console sink and it works pretty well but it logs to the lambda group. If json is written to message just like serilog console sink is doing, everything will work but |
There might be something OFF the way normal implementation works but this article gives the right way to implement structured logging for Cloudwatch. https://www.rahulpnath.com/blog/amazon-cloudwatch-logs-dotnet/ |
The steps in the article do not still produce structured logs. Does anyone have an idea on how to address this issue? When I run the application locally and log in to cloud watch, the structured logs are shown correctly, but when the lambda is deployed and runs, the logs show in plaintext, and all the enrich information are lost. |
@louisobasohan You can switch to |
Serilog.Sinks.AwsCloudWatch is also giving me the same output. Also, I'm using .NET6 |
I guess you are missing the Formatter. |
Thanks Wahmedswl, writing to console with the JsonFormatter solved the issue. I didnt need to add the additional filters.
|
@louisobasohan Yes, if you writing to the log group of Lambda, you just need |
I get logs to cloudwatch however variables are not recognized inside aws cloudwatch.
This is my configuration:
If I use alternative Serilog.Sinks.AwsCloudWatch then I get variables inside cloudwatch but I can't figure out how to remove logs
from Microsoft and would rather use this official library.
Inide Program.cs I have this:
The text was updated successfully, but these errors were encountered: