question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plus sign "+" causes one curly braces to go missing

See original GitHub issue

Does this issue relate to a new feature or an existing bug?

  • Bug
  • New Feature

Version of Serilog affected Serilog 2.5.0

Target framework

  • netCore 2.0
  • netCore 1.0
  • 4.7
  • 4.6.x
  • 4.5.x

Current behavior? Logging a string that contains json with a plus sign “+” causes one of the last curly braces to go missing.

Seems to only be an issue when there is two curly braces at the end of an object. See the example code below.

Expected behavior? I would expect a + sign to not have this side effect.

If the current behavior is a bug, please provide the steps to reproduce the issue and if possible a minimal demo of the problem

var log = new LoggerConfiguration()
                .WriteTo.Debug()
                .CreateLogger();

log.Information("{\"id\":\"+\"}");
log.Information("{\"obj\":{\"id\":\"+\"}}");  // This will miss } at end in log
log.Information("[{\"obj1\":{\"id\":\"+\"}}, {\"obj2\":{\"id\":\".\"}}]");  // This will miss } at end of first object
log.Information("[{\"obj1\":{\"id\":\"+\"}}, {\"obj2\":{\"id\":\"+\"}}]");  // This will miss } at end of first object and last
log.Information("{\"obj\":{\"id\":\".\"}}");
log.Information("{t}", "{\"obj\":{\"id\":\"+\"}}"); // Workaround

Gives output [13:05:56 INF] {“id”:“+”} [13:05:56 INF] {“obj”:{“id”:“+”} <-- Notice missing } at end [13:05:56 INF] [{“obj1”:{“id”:“+”}, {“obj2”:{“id”:“.”}}] <-- Missing } at end of first object [13:05:56 INF] [{“obj1”:{“id”:“+”}, {“obj2”:{“id”:“+”}] <-- Missing } at end of both objects [13:05:56 INF] {“obj”:{“id”:“.”}} [13:05:56 INF] {“obj”:{“id”:“+”}}

A workaround by passing it in as a argument works, but i don’t think this is expected behaviour.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
zleepycommented, Sep 13, 2019

@bartelink You sure know how to trigger a coder. And @nblumhardt kindly pointed me in the right direction. So now i don’t have any excuses. 😉

Anyhow, big thanks for helping me out! And thanks for Serilog!

0reactions
nblumhardtcommented, Sep 12, 2019

👍 I think it’s here:

https://github.com/serilog/serilog/blob/dev/src/Serilog/Parsing/MessageTemplateParser.cs#L251

> char.IsPunctuation('+')
false
> char.IsPunctuation('.')
true

The IsValidInFormat() method is a little bit suspect in how specific it is, given the variety of possible format specifiers, but that’s tangential 😃

Thanks for raising the issue @zleepy , hope this answers your question, let us know if not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding find(1)'s -exec option (curly braces & plus ...
The curly braces will be replaced by the results of the find command, and the chmod will be run on each of them....
Read more >
Curly brace error occurring when curly braces are closed ...
The problem here stems from the somewhat greedy nature of the subscript routine when you use. O_\vec{E}. It grabs \vec without it's argument ......
Read more >
im a beginner, i need help. Why does it say "missing right ...
'if' statements with a single line in the body don't require surrounding brackets, but are often strongly recommended for clarity, and as a ......
Read more >
SyntaxError: missing } after function body - MDN Web Docs
There is a syntax mistake when creating a function somewhere. Also check if any closing curly brackets or parenthesis are in the correct...
Read more >
Curly Braces: To Cuddle or Not?
Should you place curly braces on the same line as the statement (cuddle), or on the next line? It's a debate that has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found