I have created a standalone reproduction of issue here: https://github.com/GuerrillaCoder/HangfireLoggingTest
<ItemGroup> <PackageReference Include="Hangfire.AspNetCore" Version="1.7.12" /> <PackageReference Include="Hangfire.Console" Version="1.4.2" /> <PackageReference Include="Hangfire.Core" Version="1.7.12" /> <PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" /> <PackageReference Include="NLog.Web.AspNetCore" Version="4.9.3" /> </ItemGroup>
Hangfire never writes anything to logs which makes it very difficult to debug issues with tasks stalling or failing.
I believe I have followed the instructions correctly and set LogLevel to Trace but nothing is written to logs apart from when I directly send message to the Nlog logger.
Step to reproduce
- git clone https://github.com/GuerrillaCoder/HangfireLoggingTest
- run project (observe that logs are created in LogOutput folder and message is written showing NLog is working)
- Navigate to /hangfire and manually trigger task
- Observe hangfire has not written any log messages at all