-
Notifications
You must be signed in to change notification settings - Fork 151
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
Layout ILogger scopes (ILogger.BeginScope) ? #78
Comments
Hey! could you give an example? |
Hi, see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging in section "Log scopes", example from link: public IActionResult GetById(string id)
{
TodoItem item;
using (_logger.BeginScope("Message attached to logs created in the using block"))
{
_logger.LogInformation(LoggingEvents.GET_ITEM, "Getting item {ID}", id);
item = _todoRepository.Find(id);
if (item == null)
{
_logger.LogWarning(LoggingEvents.GET_ITEM_NOTFOUND, "GetById({ID}) NOT FOUND", id);
return NotFound();
}
}
return new ObjectResult(item);
} |
for more options: https://github.com/NLog/NLog/wiki/Ndc-Layout-Renderer |
I assume your question has been answered, if not, let us know! |
@304NotModified is there any additional config needed to make this work? What I have so far:
But my output has empty strings where the |
It should be See also some examples in the unit tests |
|
Thanks, I added a link in the sidebar of https://github.com/NLog/NLog/wiki |
Thanks for the links. |
New (in V5) is to use And And And |
v1.0.0-rtm-alpha5
Hi,
Is there any way I can render ILogger scopes (ILogger.BeginScope) in the NLog layout configuration for dotnetcore?
Thanks!
The text was updated successfully, but these errors were encountered: