Skip to content

Conversation

jonnybi
Copy link

@jonnybi jonnybi commented Nov 28, 2019

Added "force stringification" support as described in serilog documentation.

Copy link
Member

@nblumhardt nblumhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for spotting this gap! Just had one comment.

}
else if (property.Key.StartsWith("$"))
{
if (logger.BindProperty(property.Key.Substring(1), property.Value?.ToString() ?? "null", true, out var stringified))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Substituting in the text null will be inconsistent with Serilog here, I think. We should just pass null if property.Value is null.

@nblumhardt
Copy link
Member

@jonnybi hi! I just spotted one more place where we special-case @, which I think should also accept $ for the sake of consistency:

https://github.com/serilog/serilog-extensions-logging/blob/dev/src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerScope.cs#L75

@jonnybi
Copy link
Author

jonnybi commented Nov 30, 2019

@nblumhardt thx for spotting this. i will check it


if (key.StartsWith("$"))
{
key = key.Substring(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value would also have to be ToString()ed in order for this to take effect.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sry, i was a little too fast. Fixed it again and added a unit test.

@nblumhardt nblumhardt merged commit 6152c32 into serilog:dev Dec 11, 2019
@nblumhardt
Copy link
Member

Thanks! 👍

@nblumhardt nblumhardt mentioned this pull request Nov 1, 2021
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

Successfully merging this pull request may close these issues.

3 participants