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

[BUG] - Ambiguous reference configuring logging to ElasticCloud #458

Open
raanam opened this issue Oct 25, 2024 · 3 comments
Open

[BUG] - Ambiguous reference configuring logging to ElasticCloud #458

raanam opened this issue Oct 25, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@raanam
Copy link

raanam commented Oct 25, 2024

ECS integration/library project(s) (e.g. Elastic.CommonSchema.Serilog): Elastic.Serilog.Sinks - Version - 8.12.*

ECS schema version (e.g. 1.4.0):

ECS .NET assembly version (e.g. 1.4.2):

Elasticsearch version (if applicable):

.NET framework / OS: 8

Description of the problem, including expected versus actual behavior:

Trying to configure Elastic Search Sink in following way

Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.ElasticCloud("***", "***","***") .CreateLogger()

Results in following compilation error

Severity Code Description Project File Line Suppression State
Error (active) CS0121 The call is ambiguous between the following methods or properties: 'ConfigSinkExtensions.ElasticCloud(LoggerSinkConfiguration, string, string, string, Action?, Action?, LoggingLevelSwitch?, LogEventLevel)' and 'ElasticsearchSinkExtensions.ElasticCloud(LoggerSinkConfiguration, string, string, string, Action?, Action?, LoggingLevelSwitch?, LogEventLevel)' Wellzio.TestConnectivity C:\Repositories\Wellzio\Wellzio.TestConnectivity\Wellzio.TestConnectivity\Program.cs 13

Steps to reproduce:

  1. Create a .net 8 web api project
  2. Reference Elastic.Serilog.Sinks - package - 8.12.*
  3. Configure logger as mentioned above to see compile time error
    This problem is also reported here - https://discuss.elastic.co/t/ambiguous-reference-configuring-logging-to-elasticcloud-in-elastic-serilog-sinks/368372
@raanam raanam added the bug Something isn't working label Oct 25, 2024
@TimVerheul
Copy link

We have this as well, issue started at 8.12.0
Issue isn't present at 8.11.1

@raanam
Copy link
Author

raanam commented Nov 12, 2024

Not sure how actively this repo is being maintained but the bug is stilling here since 3 weeks without any attention.

@jb1361
Copy link

jb1361 commented Nov 13, 2024

Bug is being caused by the same signature in ElasticsearchSinkExtensions.cs and ConfigSinkExtensions.cs. Normally you can easily workaround this with a using targeting the specific class. Since these are extension methods I didn't see a way to do it So I did this instead.

internal static class ElasticSinkExtensionHelper
   {
       public static LoggerConfiguration ElasticCloud(
           this LoggerSinkConfiguration loggerConfiguration,
           string cloudId,
           string username,
           string password,
           Action<ElasticsearchSinkOptions>? configureOptions = null,
           Action<TransportConfiguration>? configureTransport = null,
           LoggingLevelSwitch? levelSwitch = null,
           LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum
       )
       {
           return ElasticsearchSinkExtensions.ElasticCloud(loggerConfiguration, cloudId, username, password, configureOptions,
               configureTransport, levelSwitch, restrictedToMinimumLevel);
       }
   }

I didn't see any difference in the implementations so either class should be fine to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants