Guidelines for service output log format

We have a Fastify (Node) app running on a render Web service which outputs logs in a JSON format (default for Fastify which uses pino to handle logs).

Setup is pretty similar to GitHub - render-examples/fastify-hello-world app.

We log some of the 4xx requests with the Info severity, however log message may an Error phrase.
In effect these are being shown as Errors in the render in-dashboard log:

{"level":30,"time":"2024-01-25T21:43:04.461Z","pid":66,"hostname":"srv-xxx-xxx-xxx","reqId":"req-7g7r","res":{"statusCode":400},"err":{"type":"Error","message":"Validation failed"}}

I am wondering what is the recommended format for output logs that will be correctly parsed by render?

We are thinking about streaming logs to an external provider however I’m not sure severity levels will be correctly parsed.

The docs says:

If you’re using a standard format like logfmt or json, Render maps the level field to an appropriate syslog priority. Otherwise, Render makes a best effort to parse log levels, defaulting to INFO.

Does it mean that the expected output is

{"level":30, "message": "..."}

or

{"level":"INFO", "message": "..."}

or any other like RFC5424?

By the way, pino’s severities are defined here:

Hi there,

I’m looking into this for you. There is a problem I see, how do we know that info = 30? The int values of logging levels seem to differ between frameworks. Here are some examples:

Regards,

Keith
Render Support, UTC+10 :australia:

Yes, AFAIK there is no standard for JSON format other that it’s a JSON.

Render In-dashboard logs docs have an example where info = 30 but in my experience whenever there is a error keyword it’s translated to error severity.

I think docs should have some best practices on how to format logs so output is understood properly by render parser and passed correctly to stream providers.

There is one more example of a JSON log format with level: 30 interpreted as Info severity:
first screenshot at A New Log Explorer and HTTP Logs blog post.

Hi there,

I agree this could be documented better.

As for the example, it’s hard to tell if it has been parsed as INFO because its 30 or because INFO is the default.

Regards,

Keith
Render Support, UTC+10 :australia:

I’m pretty sure that in the examples logs are parsed as INFO because it’s the default level when render can’t determine log entry severity.

I’d expect guidelines for app log output such as:

To help Render parse your app logs, use standard format such as logfmt or json with level field that can be mapped to appropriate syslog priority.

Example:
{"level":"INFO","time":"2024-01-25T21:43:04.461Z","pid":66,"hostname":"srv-xxx-xxx-xxx","reqId":"req-7g7r","res":{"statusCode":400},"err":{"type":"Error","message":"Validation failed"}}

… given that my assumption is correct.

Above is based on Log Streams | Render Docs

Hi, can we have an update here?

Am I correct that following strings should be used for log levels (debug | info | notice | warning | error | critical | alert | emergency) ?

In that case, should we use lowercase as in dashboard logs or uppercase format?

Hi there,

Log levels are down-cased when we perform our level matching, so it shouldn’t matter if you use upper or lowercase.

Regards,

Keith
Render Support, UTC+10 :australia:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.