# LogStash HTTP Appender
The logstash appenders for Ts.ED Logger (opens new window) send NDJSON formatted log events to logstash (opens new window) receivers. This appender uses HTTP to send the events (there is another logstash appender that uses UDP).
npm install --save @tsed/logger-logstash-http
1
# Configuration
type
-logstash-http
options.url
-string
- logFaces receiver servlet URLoptions.application
-string
(optional) - used to identify your application's logsoptions.logChannel
-string
(optional) - also used to identify your application's logs [but in a more specific way]options.logType
-string
(optional) - used for thetype
field in the logstash dataoptions.timeout
-integer
(optional, defaults to 5000ms) - the timeout for the HTTP request.options.delayToFlush
-integer
(optional, defaults to 0) - the delay before flushing buffer if the max buffer isn't reached.options.maxBuffer
-integer
(optional, defaults to 0) - Group bulk request by the maxBuffer number. By Default the buffer is disabled.options.retriesOptions
-object
(optional) - Configure retries strategy. See axios-retry (opens new window) options for more details.
This appender will also pick up Logger context values from the events, and add them as p_
values in the logFaces event. See the example below for more details.
# Example
import {Logger} from "@tsed/logger";
import "@tsed/logger-logstash-http";
const logger = new Logger("loggerName");
logger.appenders.set("stdout", {
type: "logstash-http",
level: ["info"],
options: {
url: "http://localhost:9200/_bulk",
application: "logstash-tsed",
logType: "application",
logChannel: "node"
}
});
logger.context.set("requestId", "123");
logger.info("some interesting log message");
logger.error("something has gone wrong");
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
Enable date log rolling:
import {Logger} from "@tsed/logger";
import "@tsed/logger-logstash-http";
const logger = new Logger("loggerName");
logger.appenders.set("stdout", {
type: "logstash-http",
level: ["info"],
options: {
url: "http://localhost:9200/_bulk",
application: () => "logstash-tsed-" + moment().format("YYYY.MM.DD"),
logType: "application",
logChannel: "node"
}
});
logger.context.set("requestId", "123");
logger.info("some interesting log message");
logger.error("something has gone wrong");
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 example will result in two log events being sent to your localhost:9200
.
Both events will have a context.requestId
property with a value of 123
.
Last Updated: 10/26/2023, 6:30:07 AM
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