Logging in Grasshopper

I’ve been developing a Grasshopper plugin and can’t find an access point for the Grasshoper plugin that would allow me to initialize logging using Serilog. I assume there is a class that can be overridden to allow me to run code on initialization of the plugin.

Below is the code I need to run.

var log = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .WriteTo.File("logs\\myapp.txt", rollingInterval: RollingInterval.Day)
                .CreateLogger();
Log.Logger = log;

GH_PriorityLoad . (I think it’s called that) drive a class from that and it will get constructed and called on load. You can also abort the loading if you want from there.

Thanks @DavidRutten,

Here is the code I used based on your answer

public class OnLoad : GH_AssemblyPriority
{
    public override GH_LoadingInstruction PriorityLoad()
    {

         var log = new LoggerConfiguration()
              .MinimumLevel.Debug()
              .WriteTo.File("logs\\myapp.txt", rollingInterval: RollingInterval.Day)
              .CreateLogger();
         Log.Logger = log;

        return GH_LoadingInstruction.Proceed;
    }
}

Now I just have to figure out why the Serilog dll’s aren’t referencing into the copied over gha file. :smiley: