When creating a Serilog ILogEventEnricher everything works fine until I try to access session. Doing so throws the following error:
Session has not been configured for this application or request.
Eventually, I created a new Asp.Net MVC Application for repro and added session and serilog with everything working fine.
Then when I added the enricher I can get the httpcontext but the second I look at session it still throws the error.
Any ideas as to why session is not accessible or if there is a way around this? I know I could use middleware but I’m trying to get it to work with the enricher.
Here’s my Program.cs:
Here’s my controller accessing session fine:
Here’s my enricher: