Custom log formatter #1819
Closed
Maverick1983
started this conversation in
General
Replies: 1 comment
-
Hi, yes, you can do this with the following custom log formatter implementation, or an equivalent: import { Logger, LogFormatter } from "@aws-lambda-powertools/logger";
import { LogAttributes } from "@aws-lambda-powertools/logger/lib/types/Log.js";
import { UnformattedAttributes } from "@aws-lambda-powertools/logger/lib/types/Logger.js";
class MyLogFormatter extends LogFormatter {
public formatAttributes(attributes: UnformattedAttributes): LogAttributes {
const { message, ...rest } = attributes;
return { ...rest };
}
} You would then use the custom log formatter like this: const logger = new Logger({
logFormatter: new MyLogFormatter(),
});
logger.info("test"); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It's possible to remove 'message' field with custom log formatter?
Beta Was this translation helpful? Give feedback.
All reactions