PragmaticFlow / NBomber

Modern and flexible load testing framework for Pull and Push scenarios, designed to test any system regardless a protocol (HTTP/WebSockets/AMQP etc) or a semantic model (Pull/Push).
https://nbomber.com
Other
2.08k stars 128 forks source link

Serilog Exception when trying to run a scenario #450

Closed vRITHNER closed 2 years ago

vRITHNER commented 2 years ago

Hi, I'm try to run a scenario in a new net core 6.0 app console (c#) . My goal to request an existing API call. Some dependencies require to reference an existing Infrastructure project which use Serilog Logger. When I run the scenario, I got each time the following error: I try to add the appsettings + configuration builder but it doesn't change the outcome. It would be kind if you can help me figure out what is going on. Thanks in advance -Vince

_configuration = new ConfigurationBuilder()
                    .SetBasePath(Directory.GetCurrentDirectory())
                    .AddJsonFile("appsettings.json")
                    .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true)
                    .Build();

_loggerConfiguration = new LoggerConfiguration()
                .ReadFrom.Configuration(_configuration);

_loggerConfiguration.CreateLogger();

Unhandled exception. System.MissingMethodException: Method not found: 'Serilog.LoggerConfiguration Serilog.FileLoggerConfigurationExtensions.File(Serilog.Configuration.LoggerSinkConfiguration, System.String, Serilog.Events.LogEventLevel, System.String, System.IFormatProvider, System.Nullable1<Int64>, Serilog.Core.LoggingLevelSwitch, Boolean, Boolean, System.Nullable1, Serilog.RollingInterval, Boolean, System.Nullable1<Int32>, System.Text.Encoding, Serilog.Sinks.File.FileLifecycleHooks)'. at NBomber.Infra.Logger.attachFileLogger@31(String folder, LoggerConfiguration config) at NBomber.Infra.Logger.create(String folder, TestInfo testInfo, FSharpOption1 createConfig, FSharpOption1 configPath) at NBomber.Infra.Dependency.create(String reportFolder, TestInfo testInfo, ApplicationType appType, NodeType nodeType, NBomberContext context) at NBomber.DomainServices.NBomberRunner.run(NBomberContext context) at NBomber.FSharp.NBomberRunner.run(NBomberContext context) at NBomber.CSharp.NBomberRunner.Run(NBomberContext context) at PerfTestConsole.Program.LoadTest1(Boolean skipCache, Nullable1 siteId, Nullable1 reportingUnitId, Nullable1 parallelExecution)

yurii-hunter commented 2 years ago

Hi @vRITHNER! Could you please attach the whole project or just a test that could help to reproduce it. I will try to help you.

szamacz commented 2 years ago

I have experienced a similar problem, in my case I'm getting an exception Message: System.MissingMethodException : Method not found: 'Serilog.LoggerConfiguration Serilog.FileLoggerConfigurationExtensions.File(Serilog.Configuration.LoggerSinkConfiguration, System.String, Serilog.Events.LogEventLevel, System.String, System.IFormatProvider, System.Nullable1<Int64>, Serilog.Core.LoggingLevelSwitch, Boolean, Boolean, System.Nullable1<System.TimeSpan>, Serilog.RollingInterval, Boolean, System.Nullable1<Int32>, System.Text.Encoding, Serilog.Sinks.File.FileLifecycleHooks)'.

Stack Trace:  Logger.attachFileLogger@31(String folder, LoggerConfiguration config) Logger.create(String folder, TestInfo testInfo, FSharpOption1 createConfig, FSharpOption1 configPath) Dependency.create(String reportFolder, TestInfo testInfo, ApplicationType appType, NodeType nodeType, NBomberContext context) NBomberRunner.run(NBomberContext context) NBomberRunner.run(NBomberContext context) NBomberRunner.Run(NBomberContext context) UnitTest1.Test1()line 34

This is probably because you are using Serilog.Sinks.File in version 4.1.0 and I have in my project packages with dependencies on Serilog.Sinks.File in version 5.0. When I downgraded my packages to 4.1.0 everything is fine.

Please find a project which allows to easily reproduce the mentioned problem

Could you release a new nbomber package with Serilog.Sinks.File in version 5.0.0?

szamacz commented 2 years ago

Just checked 3.0.0-beta version of NBomber and it works fine so you already fixed that

isaacabraham commented 2 years ago

Linking to #458

AntyaDev commented 2 years ago

Hi guys,

Thanks for informing me about this issue. I published NBomber v3.0.0-beta2 which references Serilog.Sinks.File 5.0.0 Also, I updated all plugins including the enterprise version.