Closed pflajszer closed 1 year ago
ILogger
support is automatically provided by Serilog and the TestWeb project has examples: https://github.com/manigandham/serilog-sinks-googlecloudlogging/blob/5c25042e1dd98cabf5c05477db3dad4ae658da06/src/TestWeb/Program.cs#L55
Try running that project with your config and see what happens. You can also enable the Serilog SelfLog diagnostics if the issue is only with GCP.
https://github.com/serilog/serilog/wiki/Debugging-and-Diagnostics
thanks, I've missed a property in GoogleCloudLoggingSinkOptions
that I'd argue it should be set to false
by default - UseSourceContextAsLogName
.
I've explicitly set the LogName when constructing the options, but it gets overwritten by the SourceContext
.
Thanks for your help!
Ok glad its solved.
Also the options are described on the readme: https://github.com/manigandham/serilog-sinks-googlecloudlogging#sink-options
The SourceContext
setting matches the default behavior of .NET logging and is set so that you can see where a log entry comes from. This is also referred to as the category and allows for filtering by name prefix: https://learn.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line#log-category
Ah, this is insightful. Thanks a lot!
Hello, Thanks for this awesome library.
I'm having one major issue that prevents me from using this as my daily driver. No logs are written to GCP when using
ILogger
andILogger<T>
Program.cs
:The above logs the "Application starting up" log (as I'm using
Log.Information
), this also works OK outside of theProgram.cs
file. It doesn't work when injectingILogger
,ILogger<T>
fromMicrosoft.Extensions.Logging.ILogger
library. It's worth noting it also does not work withSerilog.ILogger
either.Example that does not work:
From the above, the
Log.Information
log will be written to all sinks, theILogger
message will be written to all but GCP.