pub fn init_default_subscriber_with_writer<Writer>(writer: Writer)
tracing
only.Expand description
Initialize tracing-subscriber
with default logging options, and a custom writer.
You might want to avoid writing to STDOUT in the local context via init_default_subscriber()
, if you have a high-throughput Lambdas that involve
a lot of async concurrency. Since, writing to STDOUT can briefly block your tokio runtime - ref tracing #2653.
In that case, you might prefer to use tracing_appender::NonBlocking instead - particularly if your Lambda is fairly long-running and stays warm.
Though, note that you are then responsible
for ensuring gracefuls shutdown. See [examples/graceful-shutdown
] for a complete example.
This function uses environment variables set with Lambda’s advanced logging controls if they’re configured for your function.
This subscriber sets the logging level based on environment variables:
- if AWS_LAMBDA_LOG_LEVEL
is set, it takes precedence over any other environment variables.
- if AWS_LAMBDA_LOG_LEVEL
is not set, check if RUST_LOG
is set.
- if none of those two variables are set, use INFO
as the logging level.
The logging format can also be changed based on Lambda’s advanced logging controls.
If the AWS_LAMBDA_LOG_FORMAT
environment variable is set to JSON
, the log lines will be formatted as json objects,
otherwise they will be formatted with the default tracing format.