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

EventId Not Showing in Logs #140

Open
MDornian opened this issue Mar 5, 2024 · 0 comments
Open

EventId Not Showing in Logs #140

MDornian opened this issue Mar 5, 2024 · 0 comments
Assignees

Comments

@MDornian
Copy link

MDornian commented Mar 5, 2024

Even when eventId is provided, the pattern %property{eventId} will always produce (null) in the logs.

To reproduce this problem, I modified the following file: samples\Net8.0\WebApi\Controllers\WeatherForecastController.

        // Added the following 2 lines
        EventId eventId = 1001;
        _logger.LogWarning(eventId, "Sample with EventId");
        
        _logger.LogCritical(new Exception("ExceptionText"), "This is {weather}", weatherForecasts.First().Summary);
        _logger.LogTrace("Weather forecast ready!");

This produced the following log entry

2024-03-05 11:11:28,910  WARN Sample.WebApi.Net80.Controllers.WeatherForecastController.Get [(null)] [32] - MESSAGE: Sample with EventId

I would have expected

2024-03-05 11:11:28,910  WARN Sample.WebApi.Net80.Controllers.WeatherForecastController.Get [1001] [32] - MESSAGE: Sample with EventId

Just a reminder that the log4net.config has the following conversion pattern

<layout type="log4net.Layout.PatternLayout">
		<conversionPattern value="%date %5level %logger.%method [%property{eventId}] [%line] - MESSAGE: %message%newline %exception" />
</layout>
@huorswords huorswords self-assigned this Mar 8, 2024
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

2 participants