Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Configuring Custom Log Formatter in Lambda #2117

Unanswered
JasonBock asked this question in Q&A
Discussion options

Where I work, we have a custom log formatter defined that inherits from ConsoleFormatter. This lets us log our content based on an internal standard that uses a JSON format for data configured in a specific way. This works great for console applications, web apps using Blazor, apps hosted in k8s, etc. However, with an AWS Lambda, we can't find a way to get a lambda to use our custom formatter, even when we explicitly configure .NET logging to use our formatter. Seems like AWS lambda infrastructure just ignores that, and only "Text" or "Json" are the only way log in a lambda. There seems like there might be an alternative option in using AWS Powertools, but that would require our lambda users to use Powertools and it also seems like we'd have to build another formatter just for Powertools.

So, long story short: is there a way to use a custom .NET log formatter in a lambda?

You must be logged in to vote

Replies: 2 comments

Comment options

Hi @JasonBock. There isn't a mechanism right now to provide your own formatter. I need to double check how flexible the Lambda service can be on the format. I'm pretty sure they do require some fields to be in a certain locations for their analytics.

You must be logged in to vote
0 replies
Comment options

@normj that would be disappointing. We have a standard JSON format for all of our log messages, and not being able to format a log message to meet that need is a hindrance. That said, would using AWS Powertools be a possible solution? Reading up on it, it seems like we'd still have to write a custom formatter specifically for Powertools (https://docs.powertools.aws.dev/lambda/dotnet/core/logging/#custom-log-formatter-bring-your-own-formatter), but it would let us log using our structure.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /