Home » Java » java – How to launch logback + logstash on local machine?-Exceptionshub

java – How to launch logback + logstash on local machine?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have to test some features on logback + logstash bunch with tcp connection. I have downloaded logstash application. Configured that like this:

input {
tcp {
    port => "4560"
    codec => json_lines
}

} output {
  stdout { codec => rubydebug } 
}

start it with

.\bin\logstash.bat -f .\config\logstash-tcp.conf

It was start with message:

[2020-02-18T10:33:23,910][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}

Now, i have a Java app in my ide, which one should log info with logback into local lockstash via tcp connection. I have logback.xml file configured like this:

    <appender name="LOGSTASH_TCP" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
    <destination>127.0.0.1:4560</destination>
    <writeBufferSize>65536</writeBufferSize>
    <ringBufferSize>65536</ringBufferSize>
    <reconnectionDelay>5 second</reconnectionDelay>
    <droppedWarnFrequency>100</droppedWarnFrequency>
    <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>

<root level="debug">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="LOGSTASH_TCP"/>
</root>

Now, when i’am trying to log somthing, in logstash console i seeing that message:

[2020-02-18T10:40:23,373][ERROR][logstash.inputs.tcp      ][main] Error in Netty pipeline: java.io.IOException: An existing connection was forcibly closed by the remote host

I would very appreciate if someone could help with this issue.

How to&Answers:

Ok, it was not a problem. My app really was and it’s work and shut down connection)