Open trustin opened 4 years ago
IIRC we used to have dedicated structural logging but removed it since logback / log4j can generally restructure the log well enough based on the information in the context. Is that right?
https://github.com/line/armeria/blob/master/site/src/pages/docs/advanced-structured-logging.mdx
IIRC we used to have dedicated structural logging but removed it since logback / log4j can generally restructure the log well enough based on the information in the context. Is that right?
It was removed because AccessLogWriter
or just a custom callback on RequestLog.whenComplete()
will do the same job.
I guess what the user is asking is more about the ways to customize the traditional log messages. For the case shown in the conversion, the user could achieve the goal by:
RequestContextExportingAppender
; orIt's doable by writing one's own decorator instead of using Logging{Client,Service}
, but the user will have to reimplement/fork some useful functionalities like sampling and sanitization.
Would it make sense to add one more extension point like this?
interface RequestLogMessageFormatter { // name tbd
String formatRequest(RequestContext ctx, Object sanitizedRequest);
String formatResponse(RequestContext ctx, Object sanitizedResponse);
String formatResponse(RequestContext ctx, Object sanitizedResponse, Throwable cause);
}
I'm not sure if it's a good idea or not yet, though. Just exploring.
I see - it feels unfortunate to have to add a formatter interface since the logging libraries provide their own and is sort of duplicate functionality. But I guess since slf4j doesn't provide a way to do structured logging until 2.0, it might be the only way to allow reformatting of our log messages.
Related conversation: https://line-armeria.slack.com/archives/C1NGPBUH2/p1598877787005400