I have one spring boot application which is generating logs in JSON format in console. And I want that logstash directly read that logs from console and provide to ELK.
Spring boot application logback.xml is as below:
<appender name="DATA-FILE-ROLLING" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%message%n</pattern>
</layout>
</encoder>
</appender>
and it’s generating logs as below:
{"@timestamp":"2024-06-20T09:34:36.632Z","Level":"DEBUG","Logger":"core","Thread":"main","classname":"com.app.AuditLoggerUtil","appName":"Core"}
{"@timestamp":"2024-06-20T09:34:36.648Z","Level":"DEBUG","Logger":"core","Thread":"main","classname":"com.app.AuditLoggerUtil","appName":"Core"}
I also started Elasticsearch and Logstash using below configuration:
input {
stdin {
codec => "json"
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"] # Update with your Elasticsearch host
index => "logs" # Replace with your desired index name
}
}
But when I am making http://localhost:9200/_sql to Elasticsearch with “query”: “select * from logs” it givens me rows[] so somehow it’s capturing logs.
Could someone please help me what I am missing and why it’s not reading logs from console?
(Note: I don’t want to use Kibana)