serilog-contrib / serilog-sinks-splunk

A Serilog sink that writes to Splunk
https://splunk.com
Apache License 2.0
46 stars 47 forks source link

`Method not found` while configuring sink with `WriteTo.EventCollector` #75

Closed gitting closed 6 years ago

gitting commented 7 years ago

When working in the context of Azure Functions, either locally using func cli (func host start) or once uploaded to Azure, sometimes, apparently with a certain combination of various packages/target frameworks/etc., I get the following exception during a call to create logger:

Exception while executing function: Functions.SomeFunc
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.SomeFunc ---> System.AggregateException : One or more errors occurred. ---> Method not found: 'Serilog.LoggerConfiguration Serilog.SplunkLoggingConfigurationExtensions.EventCollector(Serilog.Configuration.LoggerSinkConfiguration, System.String, System.String, System.String, System.String, System.String, System.String, System.String, Serilog.Events.LogEventLevel, System.String, System.IFormatProvider, Boolean, Int32, Int32, System.Net.Http.HttpMessageHandler)'.
   at Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.GetTaskResult(Task task) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 455
   at System.Threading.Tasks.ContinuationResultTaskFromTask`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 276
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\FunctionInvokerBase.cs : 95
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker`2.InvokeAsync[TReflected,TReturnType](TReflected instance,Object[] arguments)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments)
  …

The call producing the error is:

return new LoggerConfiguration()
    .Enrich.WithMachineName()
    .WriteTo.EventCollector(host, token)
    .WriteTo.RollingFile( ... )
    .CreateLogger()

The whole execution fails at this point, obviously. Commenting out the EventCollector line gets rid of the exception and the RollingFile continues to work fine.

It appears a few mentions of a similar problem can be found elsewhere, specifically:

It looks like in most if not all cases there's some sort of package versioning problem. For me it works when I use the following combination:

Upgrades are available for both packages listed above. Upgrading either or both causes the exception.

merbla commented 7 years ago

Thanks @gitting I will try to dig in deeper.

Any particular Azure functions setup that should be considered?

gitting commented 7 years ago

Thanks for looking into it.

I don't believe there's anything particular in my setup:

This particular time running it locally in azure-functions-core-tools@1.0.4 CLI is fine as opposed to in Azure. One other time, a few versions of the CLI and packages back, it was the other way around. I did not document what the versions were and what happened when it disappeared. That situation was more tolerable since to run it locally I'd just disable splunk sink.

merbla commented 7 years ago

More notes

merbla commented 7 years ago

@paulbouwer any resources re: Azure functions you could point me to?

merbla commented 7 years ago

Release https://github.com/serilog/serilog-sinks-seq/pull/80 may help.

paulbouwer commented 7 years ago

@merbla - any specific questions around Azure functions?

merbla commented 7 years ago

@paulbouwer i guess a listing of what TFM exists for each Azure Function environment?

May not exist 😄

merbla commented 6 years ago

Hey @gitting,

Are you still having this issue?

gitting commented 6 years ago

@merbla - I'm no longer working on the project so cannot comment. Probably good to close since no one else seems to be affected.

merbla commented 6 years ago

Closing for now.