Description
Please clearly describe what the SQL Sink is doing incorrectly:
As the title says, the latest version (5.4) causes an exception because its trying to load Microsoft.Azure.Services.AppAuthentication
which doesn't exist. I don't use any Azure services and have never referenced any in my solution. Weirdly, it works fine when debugging locally, but as soon as its published to my server (IIS 10 on Windows Server 2019 on AWS EC2) the exception is thrown and I'm greeted with an ANCM 500.30 error. I've had to revert to 5.3 to avoid the exception on the server.
Here's the exception trace for details:
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Azure.Services.AppAuthentication, Version=1.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.Azure.Services.AppAuthentication, Version=1.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Platform.AzureManagedServiceAuthenticator..ctor(Boolean useAzureManagedIdentity, String azureServiceTokenProviderResource)
at Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Dependencies.SinkDependenciesFactory.Create(String connectionString, SinkOptions sinkOptions, IFormatProvider formatProvider, ColumnOptions columnOptions, ITextFormatter logEventFormatter)
at Serilog.Sinks.MSSqlServer.MSSqlServerSink..ctor(String connectionString, SinkOptions sinkOptions, IFormatProvider formatProvider, ColumnOptions columnOptions, ITextFormatter logEventFormatter)
at Serilog.Sinks.MSSqlServer.Configuration.Factories.MSSqlServerSinkFactory.Create(String connectionString, SinkOptions sinkOptions, IFormatProvider formatProvider, ColumnOptions columnOptions, ITextFormatter logEventFormatter)
at Serilog.LoggerConfigurationMSSqlServerExtensions.MSSqlServerInternal(LoggerSinkConfiguration loggerConfiguration, String connectionString, SinkOptions sinkOptions, IConfigurationSection sinkOptionsSection, IConfiguration appConfiguration, LogEventLevel restrictedToMinimumLevel, IFormatProvider formatProvider, ColumnOptions columnOptions, IConfigurationSection columnOptionsSection, ITextFormatter logEventFormatter, IApplySystemConfiguration applySystemConfiguration, IApplyMicrosoftExtensionsConfiguration applyMicrosoftExtensionsConfiguration, IMSSqlServerSinkFactory sinkFactory)
at Serilog.LoggerConfigurationMSSqlServerExtensions.MSSqlServer(LoggerSinkConfiguration loggerConfiguration, String connectionString, SinkOptions sinkOptions, IConfigurationSection sinkOptionsSection, IConfiguration appConfiguration, LogEventLevel restrictedToMinimumLevel, IFormatProvider formatProvider, ColumnOptions columnOptions, IConfigurationSection columnOptionsSection, ITextFormatter logEventFormatter)
at Serilog.LoggerConfigurationMSSqlServerExtensions.MSSqlServer(LoggerSinkConfiguration loggerConfiguration, String connectionString, String tableName, IConfiguration appConfiguration, LogEventLevel restrictedToMinimumLevel, Int32 batchPostingLimit, Nullable`1 period, IFormatProvider formatProvider, Boolean autoCreateSqlTable, ColumnOptions columnOptions, IConfigurationSection columnOptionsSection, String schemaName, ITextFormatter logEventFormatter)
at Serilog.SerilogExtensions.ApplicationSqlServer(LoggerSinkConfiguration configuration, String connectionString) in REDACTED\Extensions\SerilogExtensions.cs:line 52
at Serilog.LoggerConfigurationExtensions.Update(LoggerConfiguration logger, HostBuilderContext builder) in REDACTED\Extensions\LoggerConfigurationExtensions.cs:line 24
at REDACTED.Program.<>c.<Main>b__0_1(HostBuilderContext builder, LoggerConfiguration logger) in REDACTED\Program.cs:line 16
at Serilog.SerilogHostBuilderExtensions.<>c__DisplayClass1_0.<UseSerilog>b__0(HostBuilderContext context, IServiceCollection collection)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at REDACTED.Program.Main(String[] args) in REDACTED\Program.cs:line 10
at REDACTED.Program.<Main>(String[] args)
Please clearly describe the expected behavior:
Not throwing an exception for Microsoft.Azure.Services.AppAuthentication
. It seems to be looking for regardless if its used or not.
List the names and versions of all Serilog packages used in the project:
- Serilog: 2.9.0
- Serilog.AspNetCore: 3.2.0
- Serilog.Sinks.MSSqlServer: 5.3.0
Target framework and operating system:
- .NET Core 3.1
- Windows Server 2019
Provide a simple reproduction of your Serilog configuration code:
N/A
Provide a simple reproduction of your Serilog configuration file, if any:
N/A
Provide a simple reproduction of your application code:
N/A