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

Adding Dynatrace Sink to .NET4.8 project causes unhandled exception on logging calls #14

Open
kiddagger-lb opened this issue Jan 10, 2024 · 0 comments

Comments

@kiddagger-lb
Copy link

Hello!

I am attempting to add Dynatrace to a legacy .NET4.8 application, and having a bit of trouble. I already had sinks turned on for the Debug window and EventLog, and had no issue with those. When I added Dynatrace, I see the following exception when a log line is attempted (*** is omitted text for confidential reasons):

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for '***.Logger.***SeriLog' threw an exception.
  Source=***.Web
  StackTrace:
   at ***.Web.Support.TestLogging() in ***.Web\Support.asmx.cs:line 29

  This exception was originally thrown at this call stack:

Inner Exception 1:
TargetInvocationException: Exception has been thrown by the target of an invocation.

Inner Exception 2:
TypeLoadException: Could not load type 'Serilog.Sinks.Http.BatchFormatters.BatchFormatter' from assembly 'Serilog.Sinks.Http, Version=8.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10'.

I am using configuration to turn on sinks. This is what my Web.config file looks like for Serilog:

	<appSettings>
		<add key="serilog:minimum-level" value="Verbose" />
		<add key="serilog:using:Debug" value="Serilog.Sinks.Debug" />
		<add key="serilog:write-to:Debug" />
		<add key="serilog:using:EventLog" value="Serilog.Sinks.EventLog" />
		<add key="serilog:write-to:EventLog.source" value="***"  />
		<add key="serilog:write-to:EventLog.restrictedToMinimumLevel" value="Warning" />
		<add key="serilog:using:Dynatrace" value="Serilog.Sinks.Dynatrace" />
		<add key="serilog:write-to:Dynatrace.ingestUrl" value="***" />
		<add key="serilog:write-to:Dynatrace.accessToken" value="***" />		
	</appSettings>

and this is the code that is creating the logger:

    public static class MySerilogger
    {
        public static readonly ILogger Logger = new LoggerConfiguration()
            .ReadFrom.AppSettings()
            .CreateLogger();
    }

and these are the nuget packages with their versions that I have for Serilog:

image
image
image

Any help would be greatly appreciated!

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

No branches or pull requests

1 participant