{"action":"created","issue":{"url":"https://api.github.com/repos/serilog/serilog/issues/1231","repository_url":"https://api.github.com/repos/serilog/serilog","labels_url":"https://api.github.com/repos/serilog/serilog/issues/1231/labels{/name}","comments_url":"https://api.github.com/repos/serilog/serilog/issues/1231/comments","events_url":"https://api.github.com/repos/serilog/serilog/issues/1231/events","html_url":"https://github.com/serilog/serilog/issues/1231","id":368200307,"node_id":"MDU6SXNzdWUzNjgyMDAzMDc=","number":1231,"title":"Combining log context properties with positional properties","user":{"login":"cocowalla","id":800977,"node_id":"MDQ6VXNlcjgwMDk3Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/800977?v=4","gravatar_id":"","url":"https://api.github.com/users/cocowalla","html_url":"https://github.com/cocowalla","followers_url":"https://api.github.com/users/cocowalla/followers","following_url":"https://api.github.com/users/cocowalla/following{/other_user}","gists_url":"https://api.github.com/users/cocowalla/gists{/gist_id}","starred_url":"https://api.github.com/users/cocowalla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cocowalla/subscriptions","organizations_url":"https://api.github.com/users/cocowalla/orgs","repos_url":"https://api.github.com/users/cocowalla/repos","events_url":"https://api.github.com/users/cocowalla/events{/privacy}","received_events_url":"https://api.github.com/users/cocowalla/received_events","type":"User","site_admin":false},"labels":[{"id":28408958,"node_id":"MDU6TGFiZWwyODQwODk1OA==","url":"https://api.github.com/repos/serilog/serilog/labels/duplicate","name":"duplicate","color":"cccccc","default":true},{"id":28408962,"node_id":"MDU6TGFiZWwyODQwODk2Mg==","url":"https://api.github.com/repos/serilog/serilog/labels/wontfix","name":"wontfix","color":"ffffff","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-10-09T13:04:56Z","updated_at":"2018-10-10T10:43:30Z","closed_at":"2018-10-09T21:46:26Z","author_association":"NONE","body":"This is a question about how to combine log context properties with positional message template properties. I've found similar issues here, but none that approach it from the same angle.\r\n\r\nTake the following example:\r\n\r\n```\r\nusing (LogContext.PushProperty(\"Myergen\", \"fit?\"))\r\n{\r\n    Log.Information(\"Message using context {Myergen}\");\r\n    Log.Information(\"Message using context {Myergen} and something {Else}\", \"the else\");\r\n}\r\n```\r\n\r\nThe 1st statement works as expected. The 2nd does not, as {Myergen} is replaced with \"the else\".\r\n\r\nI thought to work around this by using `null` as positional parameters for properties that should already exist in the log context. I first tried:\r\n```\r\nusing (LogContext.PushProperty(\"Myergen\", \"fit?\"))\r\n{\r\n    Log.Information(\"Message using context {Myergen}\", null);\r\n}\r\n```\r\nSuccess, it renders `{Myergen}` from the context! Then I tried:\r\n```\r\nusing (LogContext.PushProperty(\"Myergen\", \"fit?\"))\r\n{\r\n    Log.Information(\"Message using context {Myergen} and something {Else}\", null, \"the else\");\r\n}\r\n```\r\nAlas, it doesn't work, and replaces `{Myergen}` with `null`! I guess my first success is some kind of corner case?\r\n\r\nSo, my question: is there any way to combine context properties with positional properties, such that existing context properties are left intact? Perhaps there is some kind of constant you can pass, such as:\r\n\r\n```\r\nusing (LogContext.PushProperty(\"Myergen\", \"fit?\"))\r\n{\r\n    Log.Information(\"Message using context {Myergen} and something {Else}\", Property.FromContext, \"the else\");\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/serilog/serilog/issues/comments/428525921","html_url":"https://github.com/serilog/serilog/issues/1231#issuecomment-428525921","issue_url":"https://api.github.com/repos/serilog/serilog/issues/1231","id":428525921,"node_id":"MDEyOklzc3VlQ29tbWVudDQyODUyNTkyMQ==","user":{"login":"nblumhardt","id":342712,"node_id":"MDQ6VXNlcjM0MjcxMg==","avatar_url":"https://avatars2.githubusercontent.com/u/342712?v=4","gravatar_id":"","url":"https://api.github.com/users/nblumhardt","html_url":"https://github.com/nblumhardt","followers_url":"https://api.github.com/users/nblumhardt/followers","following_url":"https://api.github.com/users/nblumhardt/following{/other_user}","gists_url":"https://api.github.com/users/nblumhardt/gists{/gist_id}","starred_url":"https://api.github.com/users/nblumhardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nblumhardt/subscriptions","organizations_url":"https://api.github.com/users/nblumhardt/orgs","repos_url":"https://api.github.com/users/nblumhardt/repos","events_url":"https://api.github.com/users/nblumhardt/events{/privacy}","received_events_url":"https://api.github.com/users/nblumhardt/received_events","type":"User","site_admin":false},"created_at":"2018-10-10T10:43:30Z","updated_at":"2018-10-10T10:43:30Z","author_association":"MEMBER","body":"Sorry @cocowalla - I didn't mean to close it as unreasonable, only that this design choice is baked pretty deeply in, and not something I think is changeable at this point. IIRC, the linked thread's pretty extensive, but happy to discuss further if you think there's a closeable gap 👍 "}}
{"actor":{"display_login":"nblumhardt"}}