Logging icon indicating copy to clipboard operation
Logging copied to clipboard

SEQ: structured logging not implemented

Open gahujipo opened this issue 5 years ago • 4 comments

I'd really like to use SEQ as logging target. It fails for every Write-Log command, because there is a problem in serializing the JSON, which I already fixed here: https://github.com/acsdatasystems/Logging/commit/c0980fa72b3275038638704edfc48c02310d6733 but haven't merged yet.

With these changes, logs are coming to the SEQ server. But it seems, that there isn't implemented any structured logging. How can I get the original log message? E.g.

Write-Log -Message "Hello {0}!" -Arguments "PowerShell"

in that case I would need Hello {0}! instead of Hello PowerShell!. I would need that, because I have to send a JSON to the server where the message cannot contain the value, but only a key and the value for that key somewhere else.

{
    "Events": [
        {
            "MessageTemplate": "Hello {Who}!",
            "Timestamp": "2020-05-29T16:46:09.3034428+02:00",
            "Level": null,
            "Properties": {
                "Who": "World"
            }
        }
    ]
}

The passed $Log variable doesn't seem to contain such a message template. Is there another way to get the original template?

gahujipo avatar May 29 '20 14:05 gahujipo

Right now we cannot implement strucuterd logging (although I'd like it) cause the form Write-Log -Message 'Hello, {0}!' -Arguments 'Powershell' uses powershell string formatting and doesn't work on named parameters (the {Who}).

We need to write our custom string formatting to propagate the raw string down to the logging target.

EsOsO avatar Jun 01 '20 06:06 EsOsO

@EsOsO How is the current status, I could add the feature next week.

tosoikea avatar Mar 04 '21 10:03 tosoikea

Please go on, I didn't write anything yet.

EsOsO avatar Mar 15 '21 10:03 EsOsO

Hey @tosoikea, have you been able to implement this?

gahujipo avatar Jul 12 '21 10:07 gahujipo