dahlia/logtape

Feature request: restore token names used in message template

Closed this issue · 2 comments

We're using structured logging on both frontend and backend. When a log record is emitted on the frontend, it is sent to the "backend" sink. On the backend, the record is forwarded to Serilog that supports structured logs, too.

Now to the problem. Imagine I have a log record with additional properties, not used in the message template:

logger.info("Request #{requestNum} sent", {  userId: 123456,  requestNum: 123456 })

Then, the "backend" sink receives this LogRecord object:

{
  "category": ["app"],
  "level": "info",
  "timestamp": 1727100948855,
  "message": ["Request #", 123456, " sent"],
  "properties": { "userId": 123456, "requestNum": 123456 }
}

Here the message doesn't contain any information that would allow to reconstruct the original template and provide it to Serilog along with the properties.

I solved this problem by forking the project and adding "rawMessage": "Request #{requestNum} sent" to LogRecord but would like to see the official support, if possible.

This is shipped with LogTape v0.6.0 (JSR & npm).

Wow, that was quick, thank you!