jzhn opened issue #9799:
Feature
Currently, the
wasmtime servealways prefixes the stdout and stderr output of http handlers. This prevents users from implementing structured logs like json.Benefit
If
wasmtime serveallows customizing log prefixes, it would allow users to implement structured logging at their http handlers, like json, so the stdout and stderr logs from wasmtime serve can be easily parsed by popular log management tools like Grafana Loki and AWS CloudWatchImplementation
Hopefully it's as simple as adding a coupld CLI flags.
Alternatives
No workarounds/alternatives I could think of.
jzhn edited issue #9799:
Feature
Currently, the
wasmtime servealways prefixes the stdout and stderr output of http handlers. This prevents users from implementing structured logs like json.Benefit
If
wasmtime serveallows customizing log prefixes, it would allow users to implement structured logging at their http handlers, like json, so the stdout and stderr logs from wasmtime serve can be easily parsed by popular log management tools like Grafana Loki and AWS CloudWatchImplementation
Hopefully it's as simple as adding a coupld CLI flags, to make https://github.com/bytecodealliance/wasmtime/blob/9aa048b0eb0caf2bbd85a24bdada33928e42ad3b/src/commands/serve.rs#L141-L149 configurable.
Alternatives
No workarounds/alternatives I could think of.
jzhn edited issue #9799:
Feature
Currently, the
wasmtime servealways prefixes the stdout and stderr output of http handlers. This prevents users from implementing structured logs like json.Expected behaviour
logging from http handler in json will be logged by
wasmtime serveas-is, without any prefixes.{"timestamp":"2024-12-12T02:01:04.794485Z","level":"INFO","fields":{"message":"hello world","log.target":"webservice","log.module_path":"webservice","log.file":"webservice/src/lib.rs","log.line":237},"target":"webservice"}Actual behaviour
handler logs are prefixed with
stdout [{req_id}] ::.stdout [176] :: {"timestamp":"2024-12-12T02:01:04.794485Z","level":"INFO","fields":{"message":"hello world","log.target":"webservice","log.module_path":"webservice","log.file":"webservice/src/lib.rs","log.line":237},"target":"webservice"}Benefit
If
wasmtime serveallows customizing log prefixes, it would allow users to implement structured logging at their http handlers, like json, so the stdout and stderr logs from wasmtime serve can be easily parsed by popular log management tools like Grafana Loki and AWS CloudWatchImplementation
Hopefully it's as simple as adding a coupld CLI flags, to make https://github.com/bytecodealliance/wasmtime/blob/9aa048b0eb0caf2bbd85a24bdada33928e42ad3b/src/commands/serve.rs#L141-L149 configurable.
Alternatives
No workarounds/alternatives I could think of.
alexcrichton commented on issue #9799:
Sounds reasonable to me to have some CLI flags for this yeah, would you be interested in sending a PR? Perhaps we could start out with a flag to just turn off the prefixes?
jzhn commented on issue #9799:
@alexcrichton : I'm fairly new to Rust and WASM, but with your encouragement I've created a PR for this. Please take a look and let me know your feedbacks. Thank you!
alexcrichton closed issue #9799:
Feature
Currently, the
wasmtime servealways prefixes the stdout and stderr output of http handlers. This prevents users from implementing structured logs like json.Expected behaviour
logging from http handler in json will be logged by
wasmtime serveas-is, without any prefixes.{"timestamp":"2024-12-12T02:01:04.794485Z","level":"INFO","fields":{"message":"hello world","log.target":"webservice","log.module_path":"webservice","log.file":"webservice/src/lib.rs","log.line":237},"target":"webservice"}Actual behaviour
handler logs are prefixed with
stdout [{req_id}] ::.stdout [176] :: {"timestamp":"2024-12-12T02:01:04.794485Z","level":"INFO","fields":{"message":"hello world","log.target":"webservice","log.module_path":"webservice","log.file":"webservice/src/lib.rs","log.line":237},"target":"webservice"}Benefit
If
wasmtime serveallows customizing log prefixes, it would allow users to implement structured logging at their http handlers, like json, so the stdout and stderr logs from wasmtime serve can be easily parsed by popular log management tools like Grafana Loki and AWS CloudWatchImplementation
Hopefully it's as simple as adding a coupld CLI flags, to make https://github.com/bytecodealliance/wasmtime/blob/9aa048b0eb0caf2bbd85a24bdada33928e42ad3b/src/commands/serve.rs#L141-L149 configurable.
Alternatives
No workarounds/alternatives I could think of.
alexcrichton commented on issue #9799:
Resolved by https://github.com/bytecodealliance/wasmtime/pull/9821
Last updated: Dec 06 2025 at 06:05 UTC