Skip to content
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

Unable to find a method called ''. Candidate methods are: #237

Closed
bruno-garcia opened this issue Sep 19, 2020 · 3 comments
Closed

Unable to find a method called ''. Candidate methods are: #237

bruno-garcia opened this issue Sep 19, 2020 · 3 comments
Labels

Comments

@bruno-garcia
Copy link

bruno-garcia commented Sep 19, 2020

When updating NuGetTrends's Serilog.Settings.Configuration from 3.1.0 to 3.2.0-dev-00244, one of the sinks stopped working.

The configuration is public, but basically this sink is the culprit:

"Name": "LogzIo",
"Args": {
	...
}

From the package:

<PackageReference Include="Serilog.Sinks.Logz.Io" Version="2.2.1" />

I have two sinks there configured via appsettings.json and the other (Sentry) works properly.

error log
2020-09-19T22:07:22.3101180Z Unable to find a method called LogzIo. Candidate methods are:
Serilog.LoggerConfiguration Sentry(Serilog.Configuration.LoggerSinkConfiguration, System.String, Serilog.Events.LogEventLevel, Serilog.Events.LogEventLevel, System.IFormatProvider, System.Nullable`1[System.Boolean], System.Nullable`1[System.Boolean], System.String, System.Nullable`1[System.Boolean], System.Nullable`1[System.Int32], System.Nullable`1[System.Single], System.String, System.String, System.Nullable`1[System.Int32], System.Nullable`1[System.TimeSpan], System.Nullable`1[System.Net.DecompressionMethods], System.Nullable`1[System.IO.Compression.CompressionLevel], System.Nullable`1[System.Boolean], System.Nullable`1[System.Boolean], System.Nullable`1[Sentry.Protocol.SentryLevel], System.Nullable`1[System.Boolean], System.Nullable`1[Sentry.DeduplicateMode], System.Nullable`1[System.Boolean])
Serilog.LoggerConfiguration Sentry(Serilog.Configuration.LoggerSinkConfiguration, System.Action`1[Sentry.Serilog.SentrySerilogOptions])
Serilog.LoggerConfiguration Providers(Serilog.Configuration.LoggerSinkConfiguration, Serilog.Extensions.Logging.LoggerProviderCollection, Serilog.Events.LogEventLevel, Serilog.Core.LoggingLevelSwitch)
Serilog.LoggerConfiguration Console(Serilog.Configuration.LoggerSinkConfiguration, Serilog.Events.LogEventLevel, System.String, System.IFormatProvider, Serilog.Core.LoggingLevelSwitch, System.Nullable`1[Serilog.Events.LogEventLevel], Serilog.Sinks.SystemConsole.Themes.ConsoleTheme, Boolean, System.Object)
Serilog.LoggerConfiguration Console(Serilog.Configuration.LoggerSinkConfiguration, Serilog.Formatting.ITextFormatter, Serilog.Events.LogEventLevel, Serilog.Core.LoggingLevelSwitch, System.Nullable`1[Serilog.Events.LogEventLevel], System.Object)
Serilog.LoggerConfiguration Debug(Serilog.Configuration.LoggerSinkConfiguration, Serilog.Events.LogEventLevel, System.String, System.IFormatProvider, Serilog.Core.LoggingLevelSwitch)
Serilog.LoggerConfiguration Debug(Serilog.Configuration.LoggerSinkConfiguration, Serilog.Formatting.ITextFormatter, Serilog.Events.LogEventLevel, Serilog.Core.LoggingLevelSwitch)
Serilog.LoggerConfiguration File(Serilog.Configuration.LoggerSinkConfiguration, System.String, Serilog.Events.LogEventLevel, System.String, System.IFormatProvider, System.Nullable`1[System.Int64], Serilog.Core.LoggingLevelSwitch, Boolean, Boolean, System.Nullable`1[System.TimeSpan])
Serilog.LoggerConfiguration File(Serilog.Configuration.LoggerSinkConfiguration, Serilog.Formatting.ITextFormatter, System.String, Serilog.Events.LogEventLevel, System.Nullable`1[System.Int64], Serilog.Core.LoggingLevelSwitch, Boolean, Boolean, System.Nullable`1[System.TimeSpan])
Serilog.LoggerConfiguration File(Serilog.Configuration.LoggerSinkConfiguration, System.String, Serilog.Events.LogEventLevel, System.String, System.IFormatProvider, System.Nullable`1[System.Int64], Serilog.Core.LoggingLevelSwitch, Boolean, Boolean, System.Nullable`1[System.TimeSpan], Serilog.RollingInterval, Boolean, System.Nullable`1[System.Int32], System.Text.Encoding)
Serilog.LoggerConfiguration File(Serilog.Configuration.LoggerSinkConfiguration, Serilog.Formatting.ITextFormatter, System.String, Serilog.Events.LogEventLevel, System.Nullable`1[System.Int64], Serilog.Core.LoggingLevelSwitch, Boolean, Boolean, System.Nullable`1[System.TimeSpan], Serilog.RollingInterval, Boolean, System.Nullable`1[System.Int32], System.Text.Encoding)
Serilog.LoggerConfiguration File(Serilog.Configuration.LoggerSinkConfiguration, System.String, Serilog.Events.LogEventLevel, System.String, System.IFormatProvider, System.Nullable`1[System.Int64], Serilog.Core.LoggingLevelSwitch, Boolean, Boolean, System.Nullable`1[System.TimeSpan], Serilog.RollingInterval, Boolean, System.Nullable`1[System.Int32], System.Text.Encoding, Serilog.Sinks.File.FileLifecycleHooks)
Serilog.LoggerConfiguration File(Serilog.Configuration.LoggerSinkConfiguration, Serilog.Formatting.ITextFormatter, System.String, Serilog.Events.LogEventLevel, System.Nullable`1[System.Int64], Serilog.Core.LoggingLevelSwitch, Boolean, Boolean, System.Nullable`1[System.TimeSpan], Serilog.RollingInterval, Boolean, System.Nullable`1[System.Int32], System.Text.Encoding, Serilog.Sinks.File.FileLifecycleHooks)
Serilog.LoggerConfiguration Sink(Serilog.Configuration.LoggerSinkConfiguration, Serilog.Core.ILogEventSink, Serilog.Events.LogEventLevel, Serilog.Core.LoggingLevelSwitch)
Serilog.LoggerConfiguration Logger(Serilog.Configuration.LoggerSinkConfiguration, System.Action`1[Serilog.LoggerConfiguration], Serilog.Events.LogEventLevel, Serilog.Core.LoggingLevelSwitch)

@skomis-mm skomis-mm added the bug label Sep 20, 2020
@nblumhardt
Copy link
Member

Thanks for this 👍

@Vincent-NET
Copy link

Hello, I have the same issue with RabbitMQ.

here is the error. i check the file and debug sinks are in there, but not RabbitMQ.
not sure if the Using is needed, but I tried many different ways, all come up with the same error.

2020-10-27T15:01:41.3101695Z Unable to find a method called RabbitMQ for supplied arguments: clientConfiguration. Candidate methods are:
RabbitMQ(configure)
RabbitMQ(clientConfiguration, sinkConfiguration, textFormatter)
RabbitMQ(hostname, username, password, exchange, exchangeType, deliveryMode, routeKey, port, vHost, heartbeat, protocol, batchPostingLimit, period, formatter, formatProvider)
RabbitMQ(hostnames, username, password, exchange, exchangeType, deliveryMode, routeKey, port, vHost, heartbeat, protocol, batchPostingLimit, period, formatter)
The program '[48880] testapp.exe: Program Trace' has exited with code 0 (0x0).
The program '[48880] testapp.exe' has exited with code 0 (0x0).

here is the code:

          Serilog.Debugging.SelfLog.Enable(msg => Debug.WriteLine(msg));

            var configuration = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                .Build();

            Log.Logger = new LoggerConfiguration()
                .ReadFrom.Configuration(configuration)
                .CreateLogger();

here is the setting

{

 "AllowedHosts": "*",
 "Serilog": {
   "Using": ["Serilog.Sinks.RabbitMQ"],
   "MinimumLevel": {
     "Default": "Information",
     "Override": {
       "Microsoft": "Warning",
       "System": "Information"
     }
   },
   "Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ],
   "WriteTo": [
     { "Name": "Console" },
     {
       "Name": "File",
       "Args": {
         "path": "C:\\Temp\\Serilog\\Serilog.txt",
         "outputTemplate": "{Timestamp:G} {Message}{Newline:1}{Exception:1}"
       }
     },
     {
       "Name": "RabbitMQ",
       "Args": {
         "clientConfiguration": {
           "Hostnames": [
             "<host>"
           ],
           "Exchange": "<exchange>",
           "ExchangeType": "direct",
           "DeliveryMode": "Durable",
           "RouteKey": "<routekey>",
           "Port": 5672,
           "Password": "<password>",
           "Username": "<username>"
         }
       }
     }

   ]
 }
}

Project Properties

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
    <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
    <PackageReference Include="Serilog.Sinks.RabbitMQ" Version="3.0.6" />
    <PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
  </ItemGroup>

</Project>

@skomis-mm
Copy link
Contributor

skomis-mm commented Nov 17, 2020

Hi, the issue occurs because Serilog.Sinks.Logz.Io references core Serilog package indirectly via Serilog.Sinks.PeriodicBatching dependency. I've added fix for this in the incoming pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants