BeerAndMala
PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
My requirements: Have a single executable, as small as possible. Therefor I use the options in the title to bundle everything into one file and turn it from 70+M to 12M (yes, it matters for this).
I need to log information during the runtime of the program and serilog would be my choice. It works fine/as expected in the debugger/while not bundled. I kinda make it work with the single executable now, but it fails to load one sink I need (serilog.sinks.eventlog). When I turn on serilogs own logging, I get the message
2024-01-10T22:55:17.8478998Z Unable to find a method called EventLog for supplied arguments: logName, manageEventSource, source. Candidate methods are:
EventLog(, , , , , , , )
EventLog(, , , , , , )
Going through the code of the project I find https://github.com/serilog/serilog-settings-configuration/blob/dev/src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs#L494 which tries to use reflection to
a) find potential matching methods (MethodInfo) - that seems to work, it does find the two "EventLog" extension methods
b) match the method with the arguments provided in serilogs configuration, using the argument names. Seems all argument names are "" though and therefor this fails
I don't believe this is serilog specific and likely more a general problem with bundling and/or trimming, but I have absolutely no idea how I could get to the bottom of this.26 replies