RabbitMQ Appender
Push log events to a RabbitMQ.
bash
npm install --save @tsed/logger-rabitmq
If you want to be sure that all messages have been sent before your programme exits, remember to call logger.shutdown()
.
Configuration
type
-rabbitmq
layout
-object
(optional, defaults tomessagePassThroughLayout
) - the layout to use for log events (see Layouts).options.host
-string
(optional, defaults to127.0.0.1
) - the location of the rabbitmq serveroptions.port
-integer
(optional, defaults to5672
) - the port the rabbitmq server is listening onoptions.username
-string
(optional, defaults toguest
) - username to use when authenticating connection to rabbitmqoptions.password
-string
(optional, defaults toguest
) - password to use when authenticating connection to rabbitmqoptions.routing_key
-string
(optional, defaults tologstash
) - rabbitmq message's routing_keyoptions.durable
-string
(optional, defaults to false) - will that RabbitMQ lose our queue.options.exchange
-string
(optional, defaults tolog
)- rabbitmq send message's exchangeoptions.mq_type
-string
(optional, defaults todirect
) - rabbitmq message's mq_typeoptions.vhost
-string
(optional, defaults to/
) - vhost to useoptions.shutdownTimeout
-integer
(optional, defaults to10000
) - maximum time in milliseconds to wait for messages to be sent during log4js shutdown.
Example
typescript
import {Logger} from "@tsed/logger";
import "@tsed/logger-rabbitmq";
const logger = new Logger("loggerName");
logger.appenders.set("stdout", {
type: "rabbitmq",
level: ["info"],
options: {
host: "127.0.0.1",
port: 5672,
username: "guest",
password: "guest",
routing_key: "logstash",
exchange: "exchange_logs",
mq_type: "direct",
durable: true
}
});
This configuration will push log messages to the rabbitmq on 127.0.0.1:5672
.