Code Monkey home page Code Monkey logo

serilog-sinks-googlecloudlogging's Introduction

serilog-sinks-googlecloudlogging's People

Contributors

alex-munteanu avatar arakis avatar bcampbell-prosper avatar crimscent avatar garethbudden avatar imperugo avatar jhasseldam avatar jimmystridh avatar manigandham avatar papamufflon avatar pardahlman avatar stasperekrestov avatar vorotech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

serilog-sinks-googlecloudlogging's Issues

Log name stays source context even when UseSourceContextAsLogName is set to false

Hey.
when i set a log name like "BasicService" and set UseSourceContextAsLogName to false the log name stays the source context. more over in the github project read me you write: "When using default options, logs will appear under these filter settings:" and then show log name default. but the default value of UseSourceContextAsLogName is true so it dont seems right.

Thanks

Feedback (EventID, Configuration)

Hi Mani.
First of all, thanks for this project. Good Job! After a while playing with this I have some feedback:

  1. Handling of EventIDs. e.g. _logging.LogDebug(eventId: 1, message: "Debug") will throw an exception in GoogleCloudLoggingSink.cs line 65.
  2. Took me a while to figure out thats its not possible to create custom log ressources. Using the default (global) now. Maybe worth to mention in the documentation that this are the supported ressources: https://cloud.google.com/logging/docs/api/v2/resource-list
  3. It would be great to add support to setting up the sink in the appconfig.json using Serilog.Settings.Configuration

Thanks
Simon

Memory traffic in Formatter

Hello,
I've been profiling an application I'm working on and found out that
LogFormatter causes some significant memory pressure.

image

image

If you don't mind I'm going to create a PR with some ideas for your review.

JsonOutput handling of c# types

The way the JsonOutput currently formats Serilog scalar values is to attempt to parse the scalar string representation into a double:

case ScalarValue scalarValue when Double.TryParse(scalarValue.Value?.ToString(), out var doubleValue):
{
    jsonStruct.Fields.Add(propertyKey, Value.ForNumber(doubleValue));
    break;
}

This leads to some undesirable side effects (eg. "000000" being added as number 0). Is there a reason not to check the c# type of the scalarValue.Value? For known number types (eg decimal, int) it would be sent as a number, but if the type is a string it would stay that way.

Can't find Logs in StackDriver

Hi, I configured the application like shown below

appsettings.yaml

Serilog:
    MinimumLevel:
        Default: Information
        Override:
            Microsoft: Information
            System: Warning

    Enrich:
        - FromLogContext
        - WithMachineName
        - WithProcessId
        - WithThreadId
    WriteTo:
        - Name: Console

appsettings.env.yaml

Using: [ "Serilog.Sinks.GoogleCloudLogging" ]
WriteTo:
  - Name: GoogleCloudLogging
    Args:
      ProjectId: <projectid>
      UseJsonOutput: true
      ResourceType: k8s_cluster
      ResourceLabels:
        ProjectId: <projectid>
        Location: europe-west1-d
        ClusterName: <cluster-name>

I also have GOOGLE_APPLICATION_CREDENTIALS environment variable set to a google credential json file

Is there a way to tell what is going on? or what I'm getting wrong?

[Suggestion] Add the log message format as a property so that entire classes of message can be filtered out

One thing that Logary's StackDriver integration did that I had some workflows around was writing the original message format before formatting to the log entry in a well-known field. For example OriginalFormat or template. This allowed for filtering in/out based on the format, which is a nice way to filter out entire classes of log messages from your view, at the cost of inflating the size of the message payload. Would this be an acceptable enhancement if it was hidden behind a configuration flag?

4.0.0 appears broken at GoogleCloudLogging

I have an application on .NET 5 using library Serilog.Sinks.GoogleCloudLogging Version="4.0.0" which is the latest version at this moment.

I have my custom logging library where Serilog is implemented to configure multiple sinks. While the logger object is being configured, I get this run time exception in the code below.

Here is the code where the sink is configured

 logger.WriteTo.GoogleCloudLogging(
      sinkOptions: config.options, 
      outputTemplate: config.OutputTemplate, 
      restrictedToMinimumLevel: config.minLevel);

Exception appears:

SysSystem.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'Void Google.Api.Gax.Grpc.ClientBuilderBase`1..ctor()'.
  Source=Google.Cloud.Logging.V2
  
  StackTrace:
   at Google.Cloud.Logging.V2.LoggingServiceV2ClientBuilder..ctor()
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSink..ctor(GoogleCloudLoggingSinkOptions sinkOptions, ITextFormatter textFormatter)
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSinkExtensions.GoogleCloudLogging(LoggerSinkConfiguration loggerConfiguration, GoogleCloudLoggingSinkOptions sinkOptions, Nullable`1 batchSizeLimit, Nullable`1 period, Nullable`1 queueLimit, String outputTemplate, ITextFormatter textFormatter, LogEventLevel restrictedToMinimumLevel, LoggingLevelSwitch levelSwitch)
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSinkExtensions.GoogleCloudLogging(LoggerSinkConfiguration loggerConfiguration, String projectId, String resourceType, String logName, Dictionary`2 labels, Dictionary`2 resourceLabels, Boolean useSourceContextAsLogName, Boolean useJsonOutput, Boolean useLogCorrelation, String googleCredentialJson, String serviceName, String serviceVersion, Nullable`1 batchSizeLimit, Nullable`1 period, Nullable`1 queueLimit, String outputTemplate, ITextFormatter textFormatter, LogEventLevel restrictedToMinimumLevel, LoggingLevelSwitch levelSwitch)
   at Lib.Logs.Log.CreateLoggerFromConfiguration() in D:\...\lib\Liblog\src\lib.logs\Logger.cs:line 87
   at Lib.Logs.Log.CreateLogger() in D:\...\lib\Liblog\src\lib.logs\Logger.cs:line 82
   at Lib.Logs.Log.Configure() in D:\...\lib\Liblog\src\lib.logs\Logger.cs:line 22
   at ChatBot.Program.Main(String[] args) in D:\...\ChatBot\Program.cs:line 25

Am I missing something to make it work?

Default True on UseSourceContextAsLogName

Is this actually a reasonable default ?

serilog for asp.net core for example uses class names including namespaces as source contexts, so it will have values like Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker, which is a disallowed log name and will throw a
Grpc.Core.RpcException: Status(StatusCode=InvalidArgument, Detail="Log name contains illegal character ") and will likely confuse new users.

how I can overwrite ProjectID in appsettings?

Hello!
I want to use different google projects for same service, but I misunderstand how I can make that?
I mean, on dev\stage\prod I uses different values for projectID

I thought it can be overwrites as env variable, like that:
Serilog__WriteTo__0__Args__projectID="project_2"
but it doesn't work :)

Which way is possible?

.Net 5 Compatibility

Hi, I am getting the following error when running a docker images that uses mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim, it previously worked fine with ASP.Net Core 3.1:

Unhandled exception. System.DllNotFoundException: Unable to load shared library 'libdl.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl.so: cannot open shared object file: No such file or directory at Grpc.Core.Internal.UnmanagedLibrary.Linux.dlopen(String filename, Int32 flags) at Grpc.Core.Internal.UnmanagedLibrary.LoadLibraryPosix(Func3 dlopenFunc, Func1 dlerrorFunc, String libraryPath, String& errorMsg) at Grpc.Core.Internal.UnmanagedLibrary.PlatformSpecificLoadLibrary(String libraryPath, String& errorMsg) at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives) at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary() at Grpc.Core.Internal.NativeExtension.LoadNativeMethods() at Grpc.Core.Internal.NativeExtension..ctor() at Grpc.Core.Internal.NativeExtension.Get() at Grpc.Core.Internal.NativeMethods.Get() at Grpc.Core.GrpcEnvironment.GrpcNativeInit() at Grpc.Core.GrpcEnvironment..ctor() at Grpc.Core.GrpcEnvironment.AddRef() at Grpc.Core.Channel..ctor(String target, ChannelCredentials credentials, IEnumerable1 options) at Google.Api.Gax.Grpc.GrpcCore.GrpcCoreAdapter.CreateChannelImpl(String endpoint, ChannelCredentials credentials, GrpcChannelOptions options) at Google.Api.Gax.Grpc.GrpcAdapter.CreateChannel(String endpoint, ChannelCredentials credentials, GrpcChannelOptions options) at Google.Api.Gax.Grpc.ChannelPool.GetChannel(GrpcAdapter grpcAdapter, String endpoint, GrpcChannelOptions channelOptions, ChannelCredentials credentials) at Google.Api.Gax.Grpc.ChannelPool.GetChannel(GrpcAdapter grpcAdapter, String endpoint, GrpcChannelOptions channelOptions) at Google.Api.Gax.Grpc.ClientBuilderBase1.CreateCallInvoker() at Google.Cloud.Logging.V2.LoggingServiceV2ClientBuilder.BuildImpl() at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSink..ctor(GoogleCloudLoggingSinkOptions sinkOptions, MessageTemplateTextFormatter messageTemplateTextFormatter) at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSinkExtensions.GoogleCloudLogging(LoggerSinkConfiguration loggerConfiguration, GoogleCloudLoggingSinkOptions sinkOptions, Nullable1 batchSizeLimit, Nullable1 period, Nullable1 queueLimit, String outputTemplate, LogEventLevel restrictedToMinimumLevel, LoggingLevelSwitch levelSwitch) at MyProject.Namespace.Infrastructure.Extensions.HostBuilderExtensions.<>c__DisplayClass1_0.<UseSerilogLogging>b__2(LoggerSinkConfiguration configure) in /src/MyProject.Namespac/Infrastructure/Extensions/HostBuilderExtensions.cs:line 55 at Serilog.Configuration.LoggerSinkConfiguration.Wrap(LoggerSinkConfiguration loggerSinkConfiguration, Func2 wrapSink, Action1 configureWrappedSink, LogEventLevel restrictedToMinimumLevel, LoggingLevelSwitch levelSwitch) at Serilog.Configuration.LoggerSinkConfiguration.Conditional(Func2 condition, Action1 configureSink) at MyProject.Namespace.Infrastructure.Extensions.HostBuilderExtensions.<>c.<UseSerilogLogging>b__1_0(HostBuilderContext hostContext, LoggerConfiguration loggerConfiguration) in /src/MyProject.Namespace/Infrastructure/Extensions/HostBuilderExtensions.cs:line 38 at Serilog.SerilogHostBuilderExtensions.<>c__DisplayClass2_0.<UseSerilog>b__0(HostBuilderContext hostBuilderContext, IServiceProvider services, LoggerConfiguration loggerConfiguration) at Serilog.SerilogHostBuilderExtensions.<>c__DisplayClass3_1.<UseSerilog>b__1(IServiceProvider services) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Serilog.SerilogHostBuilderExtensions.<>c__DisplayClass3_1.<UseSerilog>b__3(IServiceProvider services) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.Extensions.Hosting.HostBuilder.Build() at MyProject.Namespace.Program.Main(String[] args) in /src/MyProject.Namespace/Program.cs:line 12 at MyProject.Namespace.Program.<Main>(String[] args)

Has this library been updated to support Net 5 yet?

Thanks!

Suggestion: make it possible to omit 'special properties' from jsonPayload.Properties

I'm looking into using this sink to write data to Google Cloud Logging, and it looks promising - great work ๐Ÿ‘

When enabling UseLogCorrelation some properties are interpreted as special properties and assigned to corresponding properties on LogEntry. However, they are always written as "normal" properties, too. I think it would make sense if they were omitted from jsonPayload.Properties to make the entry itself more concise.

This can be achieved either by automatically detect when a "special property" is handled and skip writing it as a "normal" property, or by having a property on GoogleCloudLoggingSinkOptions to activate this behavior.

What are your thought on this?

forward logged exceptions to Error Reporting

Hi i alrady set ServiceName and ServiceVersion

var option= new GoogleCloudLoggingSinkOptions
{
    ServiceName = "TestService",
    LogName = "TestLog",
    ServiceVersion = "1.0",
    ResourceType = "generic_task",
    UseJsonOutput = true,
};

image
But my Error Reporting didn't receive any event
image
please tell me how can i forward it Thanks~~~

Cant write logs to google - permissions issue

Hi,
I created a service account with stack driver admin permissions. (admin: in order to remove permissions noice)
Downloaded the json file. and created the following config

var json = File.ReadAllText("google.json");       
var config = new GoogleCloudLoggingSinkOptions { 
         ProjectId = "prj-2496077", 
         UseJsonOutput = true,
          GoogleCredentialJson = json,
          LogName = "LogName",
          UseSourceContextAsLogName = true
 };
var log = new LoggerConfiguration().Enrich.FromLogContext()
         .WriteTo.GoogleCloudLogging(sinkOptions: config).Destructure.JsonNetTypes().CreateLogger();

the self log indicates:

2020-04-05T05:42:57.3170296Z Exception while emitting periodic batch from Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSink: Grpc.Core.RpcException: Status(StatusCode=PermissionDenied, Detail="The caller does not have permission")
   at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass0_0`2.<<WithRetry>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSink.EmitBatchAsync(IEnumerable`1 events)
   at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.OnTick()

What am I missing? whats wrong with my config?

Thanks

.NET Core logname beeing overwritten by "SourceContext"

Logname of a log entry can be passed to the constructor of GoogleCloudLoggingSinkOptions, but is always overwritten by the "SourceContext" namespace:

if (property.Key.Equals("SourceContext", StringComparison.OrdinalIgnoreCase))
entry.LogName = new LogName(_sinkOptions.ProjectId, value).ToString();

Method of transferring app to server causes error in grpc_csharp_ext.x64.dll

Describe the bug

I am using npm, grunt, and dotnet to built and deploy a dotnet new react project on osx. When this pipeline runs, the project fails to start with a 502.5 error. If I go to the server and execute dotnet app.dll I get a strange error.

Stack trace

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.IOException: Error loading native library "C:\...\runtimes/win/native\grpc_csharp_ext.x64.dll".
   at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives)
   at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
   at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
   at Grpc.Core.Internal.NativeExtension..ctor()
   at Grpc.Core.Internal.NativeExtension.Get()
   at Grpc.Core.GrpcEnvironment.GrpcNativeInit()
   at Grpc.Core.GrpcEnvironment..ctor()
   at Grpc.Core.GrpcEnvironment.AddRef()
   at Grpc.Core.Channel..ctor(String target, ChannelCredentials credentials, IEnumerable`1 options)
   at Google.Api.Gax.Grpc.ChannelPool.GetChannel(ServiceEndpoint endpoint, ChannelCredentials credentials)
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSink..ctor(GoogleCloudLoggingSinkOptions sinkOptions, MessageTemplateTextFormatter messageTemplateTextFormatter, Int32 batchSizeLimit, TimeSpan period)
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSinkExtensions.GoogleCloudLogging(LoggerSinkConfiguration loggerConfiguration, GoogleCloudLoggingSinkOptions sinkOptions, Nullable`1 batchSizeLimit, Nullable`1 period, String outputTemplate)
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSinkExtensions.GoogleCloudLogging(LoggerSinkConfiguration loggerConfiguration, String projectId, String resourceType, String logName, Dictionary`2 labels, Dictionary`2 resourceLabels, Boolean useSourceContextAsLogName, Boolean useJsonOutput, String googleCredentialJson, String serviceName, String serviceVersion, Nullable`1 batchSizeLimit, Nullable`1 period, String outputTemplate)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Serilog.Settings.Configuration.ConfigurationReader.CallConfigurationMethods(ILookup`2 methods, IList`1 configurationMethods, Object receiver)
   at Serilog.Settings.Configuration.ConfigurationReader.Configure(LoggerConfiguration loggerConfiguration)
   at Serilog.Configuration.LoggerSettingsConfiguration.Settings(ILoggerSettings settings)
   at app.Program.Main(String[] args) in /Users/.../src/Program.cs:line 17

Somewhat related issues?

grpc/grpc#11914
grpc/grpc#12570

Reproduce

Currently, I use npm scripts to run

  1. dotnet publish -c Release
  2. npm build to build the react app
  3. grunt-contrib-compress to compress the bin/release/netcoreapp2.2/publish/ folder
  4. grunt-ssh then pushes an app_offline.htm the file to a windows 2016 server running openssh to stop the app.
  5. grunt-ssh sends the publish zip and unzips the project overwriting the old app.

The strangest part is if I RDP into the server and copy the files from the same publish folder the application starts as expected.

What could possibly be causing the above error in the compression, file transfer, and uncompression process?

I posted this to aspnet core but it was closed and identified as a problem here.

from david fowler

This isn't related to ASP.NET Core or GRPC. It looks like an issue with the serilog GCP logging sink which happens to be using the native interop C# grpc implementation. The issue should be moved to this repository manigandham/serilog-sinks-googlecloudlogging

3.0.0 appears to be broken

I have to applications that use this library in the exact same way:

  1. .NET Core 3.1, Serilog.Sinks.GoogleCloudLogging version 2.4.1
  2. .NET Core 3.0, Serilog.Sinks.GoogleCloudLogging version 3.0.0

I can see the logs for application 1 in GCP, but there are no logs whatsoever for application 2.

Downgrading to version 2.4.1 in application 2 fixes the problem.

The options are very simple:

var options = new GoogleCloudLoggingSinkOptions
{
	UseJsonOutput = true,
	ServiceName = "myApp",
	ServiceVersion = "1.2.3.4
};

Do I need any other configuration to make 3.0.0 work?

Credentials file in appsettings

Does anyone know how to set the credentials file in appsettings.json? Whenever we try to do it it fails parsing at the first letter of the filename. Maybe it's looking somewhere other than the project home folder?

e.g. using this appsettings snippet:
{ "Name": "GoogleCloudLogging", "Args": { "projectID": "optii-keeper", "useJsonOutput": "true", "logName": "Optii.Pms.Api.Sms", "googleCredentialJson": "v2-gcp-logger_optii-keeper.json", "resourceType": "logging_log", "resourceLabels": { "project_id": "optii-keeper", "name": "pmsapidev.optii.net" } } }
we get this error:
JsonReaderException: Unexpected character encountered while parsing value: v. Path '', line 0, position 0.

Allow specifying queue limit in GoogleCloudLoggingSink

The base class of GoogleCloudLoggingSink, PeriodicBatchingSink, has an overload to specify queueLimit so it should be easy to add this.

However, PeriodicBatchingSink has a problem with the way default queue limit is specified so adding int queueLimit = NoQueueLimit (-1) to GoogleCloudLoggingSink constructor won't work. I've created another bug for this under serilog-sinks-periodicbatching: serilog/serilog-sinks-periodicbatching#45

The reason I am asking to specify queue limit is that we've recently encountered some memory pressure in our application when we enabled Serilog -> GCP logging for some method that's called frequently from time to time. We would like to set a queue limit so logs are dropped instead of accumulated in memory.

Payload data losing types by sending as "labels"

The cloud logging setup only allows labels to be sent as key value pairs of type "string". By putting all of the Serilog object properties as labels, they lose all their type information and are not able to be queried in many cases.

For example a simple serilog log like:

Log.Logger.Information("Value is {Count}", 10);

the count property would be attached as a label like:

{
    "count": "10"
}

Queries then could not be ran on these values using greater than or similar calculations.

An alternative would be to send the properties as part of a jsonPayLoad (or protoPayload) instead of using the textPayload. The payload would be something like:

{
    "message": "Value is 10",
    "template": "Value is {Count}",
    "properties": {
        "count": 10
     }
}

This would allow all the properties to be properly queried. What do you think?

Can i target specific sinks?

This is more of a question if one is able to target specific sinks to be able to handle retention time for specific logs?

Stackdriver Resource Labels

Hi,

So I've implemented the log as in the test project and hosted it on GCloud and it's logging fine except it's not populating the resource labels when I log an error.

It populates the labels when I log to the Console but not when I use Serilog to add an entry.

Do you know if this is a known issue with Serilog or is there something I'm not doing right?

I am using the latest version of Serilog.AspNetCore 2.1.1 and the GoogleCloudLogging 1.4.6.

Regards,

James

Map Serilog Verbose Level to Stackdriver Trace Level

I am logging some logs via Serilog and using this GoogleCloudLogging Sink. I noticed logs to Serilog's verbose Level were coming up in Stackdriver as Debug. I dug through the code a bit and found this line. Seems like a quick fix to map Serilog's verbose to Stackdriver's trace Level.

EmitBatchAsync() fails to write log messages

EmitBatchAsync() call fails to write anything when await _client.WriteLogEntriesAsync(_logNameToWrite, _resource, _sinkOptions.Labels, logEntries); is called. What is the best way to debug what is happening?

Trace is not displayed.

I have deployed an application developed in .Net 6 to Cloud Run. Although I have set UseLogCorrelation to True, the Trace is not being displayed in the output logs. Is there a mistake in my configuration?

Program.cs

var builder = WebApplication.CreateBuilder(args);

var config = new GoogleCloudLoggingSinkOptions { ProjectId = "MY_PROJECT_ID", UseLogCorrelation = true };
builder.Host.UseSerilog((ctx, lc) => lc
        .ReadFrom.Configuration(ctx.Configuration)
        .Enrich.FromLogContext()
        .WriteTo.GoogleCloudLogging(config));

Controller

Log.Information("Test Log");
_logger.LogInformation("Test Log")

Log

{
  "insertId": "6dzqzcg106aqd8",
  "jsonPayload": {
    "properties": {
      "ActionId": "5dfa3659-b6c6-4a30-a1e2-6ae582176be1",
      "RequestPath": "/Api",
      "SourceContext": "WebAPI.Controllers.ApiController",
      "RequestId": "0HN10GKCPK726:00000002",
      "ActionName": "WebAPI.Controllers.ApiController.Get (WebAPI)",
      "ConnectionId": "0HN10GKCPK726"
    },
    "message": "Test Log"
  },
  "resource": {
    "type": "cloud_run_revision",
    "labels": {
      "location": "asia-east2",
      "configuration_name": "logtest",
      "service_name": "logtest",
      "project_id": "MY_PROJECT_ID",
      "revision_name": "myproject-00029-p9s"
    }
  },
  "timestamp": "2024-01-29T04:45:22.692149600Z",
  "severity": "INFO",
  "logName": "projects/MY_PROJECT_ID/logs/WebAPI.Controllers.ApiController",
  "receiveTimestamp": "2024-01-29T04:45:33.794937066Z"
}

Service Account GCP VM

If I remove the creds.json it doesn't seem to default to using the GCP VM Service account attached to the VM. Do I need a flag so that the library will use my machine service account in google cloud? I see in the instructions "no additional steps necessary" however continually get access denied (no matter the access level I grant in IAM)

Is there any way to specify @type?

Hi!

We recently discovered a situation where error logs hadn't been detected by GCP Error Reporting. In the particular case, error messages were logged without an Exception, as there is no Exception associated with the error. Apparently this caused the errors to fly under Error Reporting's radar.

If I understand the Error Reporting docs correctly, it should be possible to set @type to type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent to allow Error Reporting to detect an Exception-less error log.

Is there any way to set @type via this library?

Thank you!

GKE no logs

Hi,
I have an application running in GCP GKE, and there are just no logs shown in google,
tried play with/without project-id etc, same result , I have Log Writer permissions on the cluster,
image

Support for Microsoft.Extensions.Logging.ILogger

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 and ILogger<T>

Program.cs:

var config = new GoogleCloudLoggingSinkOptions
{
    ProjectId = "MY_PROJECT_ID",
    GoogleCredentialJson = "MY_GOOGLE_CREDENTIALS",
    LogName = "MY_LOG_NAME",
};
Log.Logger = new LoggerConfiguration()
    .ReadFrom.Configuration(builder.Configuration)
    .MinimumLevel.Verbose()
    .WriteTo.GoogleCloudLogging(config)
    .WriteTo.Console()
    .WriteTo.Seq(serverUrl: "http://localhost:8081")
    .Enrich.FromLogContext()
    .Enrich.WithMachineName()
    .Enrich.WithProcessId()
    .Enrich.WithThreadId()
    .CreateLogger();

// Add services to the container.
builder.Services.AddApplicationServices();
builder.Services.AddInfrastructureServices(builder.Configuration);
builder.Services.AddWebUIServices();

builder.Host.UseSerilog();
Log.Information("Application starting up");
var app = builder.Build();

app.UseSerilogRequestLogging();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseOpenApi();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthentication();
app.UseAuthorization();

app.MapControllers();

app.Run();

The above logs the "Application starting up" log (as I'm using Log.Information), this also works OK outside of the Program.cs file.
It doesn't work when injecting ILogger, ILogger<T> from Microsoft.Extensions.Logging.ILogger library. It's worth noting it also does not work with Serilog.ILogger either.

Example that does not work:

using Microsoft.Extensions.Logging;

namespace MyApp;

public class SomeService
{
    private readonly ILogger _logger;

    public SomeService(ILogger<SomeService> logger)
    {
        _logger = logger;
    }

    public async Task DoSomething(CancellationToken cancellationToken)
    {
        var msg = "I'm logging something to several places";
        _logger.LogInformation(msg);
        Serilog.Log.Information(msg);
    }
}

From the above, the Log.Information log will be written to all sinks, the ILogger message will be written to all but GCP.

Potential blocking call in EmmitBatchAsync

Hi,

I think the using on the StreamWriter will invoke the sync Dispose.
did not read the code thoroughly but shouldn't that method be normal async with proper awaits everywhere isntead?

Exception is not part of the log

Hey.
when i log exceptions using serilog syntax i cant find them in the log attributes (in google viewer). do i need to add some label for them to appear?

Thanks Yosi

Warning type not in log

I've got to be doing something wrong, but I have logging setup exactly. The program is running on a VM and I see logs being written.

To test it, I put

_logger.LogWarning("warning {test}","dfd");

in my code. when going to the logs, I see the entry, but I do not see that it is a warning, seems to be saved as any.
This is my appsettings entry:

"Serilog": {
"Using": [ "Serilog.Sinks.GoogleCloudLogging" ],
"MinimumLevel": "Warning",
"WriteTo": [
{
"Name": "GoogleCloudLogging",
"Args": {
"projectID": "redacted",
"useJsonOutput": "true",
"resourceLabels": {
"project_id": "redacted",
"service_name": "api"
},
"labels": {
"service": "api"
}
}
}
]
}

Losing log messages

Hi!

Every now and then, we're unable to find log messages in StackDriver. Our containers log to stdout/stderr, so we can see that we have a text log message, but the corresponding structured JSON log entry isn't there.

We turned on Serilogs's SelfLog logging, and got this:

2022-02-04T15
54:43.1948133Z Exception while emitting periodic batch from Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink: Grpc.Core.RpcException: Status(StatusCode="InvalidArgument", Detail="Log entry with size 2.30M exceeds maximum size of 256.0K", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1643990083.192067968","description":"Error received from peer ipv4:[xx.xx.xx.xx:443](http://xx.xx.xx.xx:443/)","file":"/var/local/git/grpc/src/core/lib/surface/call.cc","file_line":1062,"grpc_message":"Log entry with size 2.30M exceeds maximum size of 256.0K","grpc_status":3}")

I'm not sure if it's the total of all entries sent to StackDriver that exceeds the max, or if it is a single entry in the batch. If it's the total, would it be possible to calculate the size beforehand and send in smaller chunks? If it's a single entry that is too big, would it be possible to drop just that one (with some suitable error logging) but send the rest?

Bug: Service not starting when using Topshelf

Hey! Thank you for your awesome library! I have this issue when using Serilog with Topshelf, the console application works as expected but when trying to start it as a service. It gives this error:

Error 1053: The service did not respond to the start or control request in a timely fashion

To Reproduce

Environment

  • .NET 5.0
  • Topshelf 4.3.0
  • Serilog 2.10.0
  • Serilog.Sinks.Console 4.0.0
  • Serilog.Sinks.GoogleCloudLogging 3.5.0
  • Topshelf.Serilog 4.3.0

Dummy Console App

using Serilog;
using Serilog.Sinks.GoogleCloudLogging;
using System;
using System.Timers;
using Topshelf;

namespace App
{
    public class TownCrier
    {
        readonly Timer _timer;
        public TownCrier()
        {
            _timer = new Timer(2000) { AutoReset = true };
            _timer.Elapsed += (sender, eventArgs) => Log.Information("All is well!");
        }
        public void Start() { _timer.Start(); }
        public void Stop() { _timer.Stop(); }
    }

    public class Program
    {
        public static void Main()
        {

            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "gckey.json");
            var config = new GoogleCloudLoggingSinkOptions { ProjectId = "dummy-project", UseJsonOutput = true, ServiceName = "demolog", LogName = "demolog" };
            // Logging
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .WriteTo.Console()
                .WriteTo.GoogleCloudLogging(config)
                .CreateLogger();

            var rc = HostFactory.Run(x =>                                   //1
            {
                x.UseSerilog();
                x.Service<TownCrier>(s =>                                   //2
                {
                    s.ConstructUsing(name => new TownCrier());                //3
                    s.WhenStarted(tc => tc.Start());                         //4
                    s.WhenStopped(tc => tc.Stop());                          //5
                });
                x.RunAsLocalSystem();                                       //6

                x.SetDescription("Sample Topshelf Host");                   //7
                x.SetDisplayName("Stuff");                                  //8
                x.SetServiceName("Stuff");                                  //9
            });                                                             //10

            var exitCode = (int)Convert.ChangeType(rc, rc.GetTypeCode());  //11
            Environment.ExitCode = exitCode;
        }
    }
}

Build and run the service

  • In a new .bat file add:
cd /d C:\PathToProject\Bin\Debug\net5.0
ProjectName.exe install
ProjectName.exe start
pause
  • Then run it as an admin

Trace fields are seems to be incorrect

Hello,
I've found out that according to

https://cloud.google.com/trace/docs/trace-log-integration

traces should have the following format
projects/[PROJECT_ID]/traces/[TRACE_ID]
however, in LogFormatter.cs code

private void CheckForSpecialProperties(LogEntry log, string key, string value)
{
    if (_useSourceContextAsLogName && key.Equals("SourceContext", StringComparison.OrdinalIgnoreCase))
        log.LogName = CreateLogName(_projectId, value);

    if (_useLogCorrelation)
    {
        if (key.Equals("TraceId", StringComparison.OrdinalIgnoreCase))
            log.Trace = $"projects/{_projectId}/traces/{key}";

        if (key.Equals("SpanId", StringComparison.OrdinalIgnoreCase))
            log.SpanId = key;
    }
}

produces Trace references like projects/vitupay-oos/traces/TraceId
SpanIds are also suspicious.

As I understand, it should be

  log.Trace = $"projects/{_projectId}/traces/{value}";
...
  log.SpanId = value;

Missing log entries

Hello,

I've configured the sink and I can see my log entries in the GCP Console. However, very large number of my logs are not there.

Here is an example of my console log output:

{"Timestamp":"2020-01-10T11:04:25.0718940+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"e4145579f55a4894a67c1fa4935f4a04","MachineName":"Dragans-MacBook-Pro","ThreadId":10}}
{"Timestamp":"2020-01-10T11:04:25.1694000+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":200,"headers":["[Date, Fri, 10 Jan 2020 10:04:24 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 72]","[X-Correlation-Id, e4145579f55a4894a67c1fa4935f4a04]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"e4145579f55a4894a67c1fa4935f4a04","MachineName":"Dragans-MacBook-Pro","ThreadId":10}}
{"Timestamp":"2020-01-10T11:04:54.3551770+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"eb2aa0ca99654ba5b74637ed0aeeab1f","MachineName":"Dragans-MacBook-Pro","ThreadId":4}}
{"Timestamp":"2020-01-10T11:04:54.3641420+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:04:53 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, eb2aa0ca99654ba5b74637ed0aeeab1f]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"eb2aa0ca99654ba5b74637ed0aeeab1f","MachineName":"Dragans-MacBook-Pro","ThreadId":4}}
{"Timestamp":"2020-01-10T11:05:20.5734090+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"091fa7d9d00b4f229fff2b8c325f2005","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:20.5748690+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:19 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 091fa7d9d00b4f229fff2b8c325f2005]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"091fa7d9d00b4f229fff2b8c325f2005","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:21.0256940+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"83d208d31a4d49dbbc346560adf2e225","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:21.0313500+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:20 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 83d208d31a4d49dbbc346560adf2e225]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"83d208d31a4d49dbbc346560adf2e225","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:26.0542250+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"edef2fe4b3c34bd38baabecc785452b8","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:26.0562250+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:25 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, edef2fe4b3c34bd38baabecc785452b8]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"edef2fe4b3c34bd38baabecc785452b8","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:26.6089760+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"c22a8340a435417a878a8a6ca7f6325c","MachineName":"Dragans-MacBook-Pro","ThreadId":12}}
{"Timestamp":"2020-01-10T11:05:26.6104780+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:25 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, c22a8340a435417a878a8a6ca7f6325c]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"c22a8340a435417a878a8a6ca7f6325c","MachineName":"Dragans-MacBook-Pro","ThreadId":12}}
{"Timestamp":"2020-01-10T11:05:27.2000710+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"3dc394d58e044d2599b491203306a697","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:27.2015120+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:26 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 3dc394d58e044d2599b491203306a697]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"3dc394d58e044d2599b491203306a697","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:28.3005700+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"fa0d8d5de32044cc8987d9cbac81c00d","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:28.3020780+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:27 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, fa0d8d5de32044cc8987d9cbac81c00d]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"fa0d8d5de32044cc8987d9cbac81c00d","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:38.3667470+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"a832a8f417dc455090b4f54a8f6db8e1","MachineName":"Dragans-MacBook-Pro","ThreadId":21}}
{"Timestamp":"2020-01-10T11:05:38.3712410+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:37 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, a832a8f417dc455090b4f54a8f6db8e1]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"a832a8f417dc455090b4f54a8f6db8e1","MachineName":"Dragans-MacBook-Pro","ThreadId":21}}
{"Timestamp":"2020-01-10T11:05:39.0143940+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"324e3804d78a4581aa87520a6d0efe75","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:39.0161660+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:38 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 324e3804d78a4581aa87520a6d0efe75]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"324e3804d78a4581aa87520a6d0efe75","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:39.3237510+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"c781c524470e405d9f71f6c8bc278b0e","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:39.3249350+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:38 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, c781c524470e405d9f71f6c8bc278b0e]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"c781c524470e405d9f71f6c8bc278b0e","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:39.5585740+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"2a1e92a95cc54a4ea3bf9dfdf6a19f3d","MachineName":"Dragans-MacBook-Pro","ThreadId":18}}
{"Timestamp":"2020-01-10T11:05:39.5599370+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:38 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 2a1e92a95cc54a4ea3bf9dfdf6a19f3d]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"2a1e92a95cc54a4ea3bf9dfdf6a19f3d","MachineName":"Dragans-MacBook-Pro","ThreadId":18}}
{"Timestamp":"2020-01-10T11:05:39.7495670+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"e2c61b94e28548d0bc581db4c31c0deb","MachineName":"Dragans-MacBook-Pro","ThreadId":20}}
{"Timestamp":"2020-01-10T11:05:39.7506290+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:38 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, e2c61b94e28548d0bc581db4c31c0deb]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"e2c61b94e28548d0bc581db4c31c0deb","MachineName":"Dragans-MacBook-Pro","ThreadId":20}}
{"Timestamp":"2020-01-10T11:05:39.9603800+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"c0884d90d73747929b46b9d33352e01d","MachineName":"Dragans-MacBook-Pro","ThreadId":15}}
{"Timestamp":"2020-01-10T11:05:39.9611280+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:38 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, c0884d90d73747929b46b9d33352e01d]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"c0884d90d73747929b46b9d33352e01d","MachineName":"Dragans-MacBook-Pro","ThreadId":15}}
{"Timestamp":"2020-01-10T11:05:40.2113760+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"5f2891dafb51485d8b2518691a671cb4","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:40.2122700+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:39 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 5f2891dafb51485d8b2518691a671cb4]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"5f2891dafb51485d8b2518691a671cb4","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:40.4606170+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"44e9fe24f5ad4d12acdf60e530019156","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:40.4614860+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:39 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 44e9fe24f5ad4d12acdf60e530019156]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"44e9fe24f5ad4d12acdf60e530019156","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:40.6800060+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"6014c148f7be405f813a8131c0058069","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:40.6808140+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:39 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 6014c148f7be405f813a8131c0058069]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"6014c148f7be405f813a8131c0058069","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:40.9107450+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"9d2bc13ac98f4813a2f36a8d4a6092f1","MachineName":"Dragans-MacBook-Pro","ThreadId":18}}
{"Timestamp":"2020-01-10T11:05:40.9115300+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:39 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 9d2bc13ac98f4813a2f36a8d4a6092f1]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"9d2bc13ac98f4813a2f36a8d4a6092f1","MachineName":"Dragans-MacBook-Pro","ThreadId":18}}
{"Timestamp":"2020-01-10T11:05:41.1436090+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"a1f1c19ccf284b64858abec5211fdd14","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:41.1441430+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:40 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, a1f1c19ccf284b64858abec5211fdd14]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"a1f1c19ccf284b64858abec5211fdd14","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:41.3763180+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"863a7755fcc7494f8bedbe105478d0c4","MachineName":"Dragans-MacBook-Pro","ThreadId":21}}
{"Timestamp":"2020-01-10T11:05:41.3777770+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:40 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 863a7755fcc7494f8bedbe105478d0c4]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"863a7755fcc7494f8bedbe105478d0c4","MachineName":"Dragans-MacBook-Pro","ThreadId":21}}
{"Timestamp":"2020-01-10T11:05:41.6278620+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"c08bf78848d540dc9b2ba2a5de26122a","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:41.6284430+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:40 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, c08bf78848d540dc9b2ba2a5de26122a]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"c08bf78848d540dc9b2ba2a5de26122a","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:41.8885000+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"dad4d12f4d244799935f0dde459b853d","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:41.8906800+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:40 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, dad4d12f4d244799935f0dde459b853d]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"dad4d12f4d244799935f0dde459b853d","MachineName":"Dragans-MacBook-Pro","ThreadId":16}}
{"Timestamp":"2020-01-10T11:05:42.1979820+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"82c2265843764655b7994570543854d0","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:42.1984540+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:41 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 82c2265843764655b7994570543854d0]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"82c2265843764655b7994570543854d0","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:42.6854430+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/ss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"6afa4bd2f15d45fab3ab6f3f1d5a66bf","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:42.6861520+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:41 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 6afa4bd2f15d45fab3ab6f3f1d5a66bf]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"6afa4bd2f15d45fab3ab6f3f1d5a66bf","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:45.5274610+01:00","Level":"Debug","MessageTemplate":"HTTP Request; {method} {url}; {headers}; {body}","Properties":{"method":"GET","url":"http://localhost:5002/sssss","headers":["[Accept, */*]","[Host, localhost:5002]","[User-Agent, curl/7.65.3]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"2d5871b524e84501aadf4c53b8a3c8b2","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}
{"Timestamp":"2020-01-10T11:05:45.5295870+01:00","Level":"Debug","MessageTemplate":"HTTP Response; {statusCode}; {headers}; {body}","Properties":{"statusCode":401,"headers":["[Date, Fri, 10 Jan 2020 10:05:44 GMT]","[Content-Type, application/json; charset=utf-8]","[Server, Kestrel]","[Content-Length, 87]","[X-Correlation-Id, 2d5871b524e84501aadf4c53b8a3c8b2]"],"body":"n/a","SourceContext":"MyProject.ServiceLib.Web.RequestResponseLoggingMiddleware","CorrelationId":"2d5871b524e84501aadf4c53b8a3c8b2","MachineName":"Dragans-MacBook-Pro","ThreadId":17}}

and my GCP Logs viewer:

image

You can see that only the first entry is there and nothing more. I have tried to log much more entries and see if they will appear in the GCP but no success.

I tried to enable Serilog internal logging to check for potential errors but nothing logged there.

Here is my configuration:

    let configureLogger googleCredentialsJsonFile =
        let file = File.CreateText ("serilog_internal.log")
        Serilog.Debugging.SelfLog.Enable(TextWriter.Synchronized(file))

        let versionInfo = getVersionInfo ()
        let applicationName = versionInfo.ProductName
        let applicationVersion = versionInfo.ProductVersion

        LogContext.PushProperty("Application", applicationName) |> ignore
        LogContext.PushProperty("ApplicationVersion", applicationVersion) |> ignore

        let googleCredentialsJson = File.ReadAllText (googleCredentialsJsonFile)

        let projectId =
            Json.deserialize<{| project_id: string |}> googleCredentialsJson
            |> fun x -> x.project_id

        Log.Logger <-
          LoggerConfiguration()
            .Destructure.FSharpTypes()
            .MinimumLevel.Debug()
            .WriteTo.Console(JsonFormatter ())
            .WriteTo.GoogleCloudLogging(
                GoogleCloudLoggingSinkOptions(
                    ProjectId=projectId,
                    UseJsonOutput=true,
                    ServiceName=applicationName,
                    ServiceVersion=applicationVersion,
                    GoogleCredentialJson=googleCredentialsJson
                )
            )
            .Enrich.FromLogContext()
            .Enrich.WithMachineName()
            .Enrich.WithThreadId()
            .CreateLogger()

The googleCredentialsJson is path to the file with credentials for service account which has admin rights and I would assume it is good as long as it manages to log at least one entry.

Please advise.

Regards,
Dragan

No more Log Entry visible

From application deployed last time on Middle December, no log entry has been found now,
no error founds in CLoud Logging

the configuration has not been changed so far:

  "Serilog": {
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Microsoft": "Error",
        "Microsoft.Hosting.Lifetime": "Information",
        "Microsoft.AspNetCore": "Warning",
        "Microsoft.AspNetCore.Hosting.Internal.WebHost": "Warning",
        "Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware": "Warning",
        "Microsoft.AspNetCore.Hosting.Diagnostics": "Warning"
      },
      "Using": [
        "Serilog.Sinks.GoogleCloudLogging",
        "Serilog.Enrichers.ClientInfo",
        "Serilog.Context.LogContext"
      ]
    },
    "Enrich": [
      "FromLogContext",
      "WithClientIp",
      "WithThreadId",
      "WithThreadName",
      "WithEnvironmentUserName",
      "WithMachineName"
    ],
    "WriteTo": [
      {
        "Name": "GoogleCloudLogging",
        "Args": {
          "projectID": "XXXXXXXXX",
          "restricedToMinimumLevel": "Information",
          "labels": {
            "env": "prod",
            "resource": "YYYYYYY"
          }
        }
      }
    ]
  },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.