As per my requirement I just wanted to post HTTP message to other end which is logged by org.slf4j.LoggerFactory.getLogger()
.
The following JSON string logged at INFO level
.
{
"studentName": "My Name",
"Deratment": "Computer Science",
"address": {
"Address Line1": "My Address Line1",
"Address Line2": "My Address Line2",
"Address Line3": "My Address Line3"
}
}
Considerations,
Http message should post with MIME type
application/json
should process only the particular log in
INFO
level not all.
Is there any built-in appender in Logback to achieve this?
If not, what is the best way to do it?
Logback works really well with logstash: https://github.com/logstash/logstash-logback-encoder.
First step would be to configure logback to logstash connection.
Once it is done, you would need to create a pipeline from tcp input to http output plugin that may look as follows
(see https://www.elastic.co/guide/en/logstash/current/plugins-outputs-http.html)