Rabbit Topic embed log level into routing key
Closed this issue · 1 comments
charithf commented
I'm interested in the rabbitmq log appender. Can I put the log level into the routing key? Is there a way to configure this? or else is there a way to access the log level via the payload?
kmacpher67 commented
what layout type: did you choose, it's configurable from the base log4js feature.
Just add it to the bottom of the rabbit {} list of config attributes:
type: '@log4js-node/rabbitmq',
protocol: 'amqps',
..... 0,
layout: { type: 'json', separator: ',' }
}
I implemented "custom" json layout, which inherited the color and everything layout.
My rabbit logs have this:
"level":{"level":20000,"levelStr":"INFO","colour":"green"}
export interface BaseLayout { type: 'basic';
export interface ColoredLayout { type: 'colored' | 'coloured';
Pick a standard layout or customize you own.
function timestampLevelAndCategory(loggingEvent, colour) {
return colorize(
util.format(
'[%s] [%s] %s - ',
dateFormat.asString(loggingEvent.startTime),
loggingEvent.level.toString(),
loggingEvent.categoryName
),
colour
);
}