# RabbitMQ Appender
Push log events to a RabbitMQ (opens new window).
npm install --save @tsed/logger-rabitmq
1
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
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
}
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
This configuration will push log messages to the rabbitmq on 127.0.0.1:5672
.
Other topics
- Console Appender
- File Appender
- Date Rolling File Appender
- Connect Appender
- Standard Out Appender
- Standard Error Appender
- Insight Appender
- LogEntries Appender
- LogStash HTTP Appender
- LogStash UDP Appender
- Loggly Appender
- RabbitMQ Appender
- Seq Appender
- Slack Appender
- SMTP Appender
- Basic layout
- Colored layout
- Dummy layout
- Message Pass-Through layout
- Object layout
- Json layout
- Pattern layout