Link log4j to a logstash docker image


(Im In Love With Cacao) #1

Hi there,

I'm currently trying to send my log4j logs to a docker image of logstash that is running on a vm.
The logstash docker image works fine by itself (when I set stdin{} or file{} as input) and log4j also works fine with a non-dockerized logstash instance.
Then I try to run a docker image of my logstash pipeline, then run the code where log4j sends the logs.
I don't get any error (such as log4j:ERROR Could not connect to remote log4j server at [deb007vm]. We will try again later.that would appear if my connection was badly set up) but I don't get any output neither on my console.

Here is my log4j.xml configuration :

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="socket" class="org.apache.log4j.net.SocketAppender">
        <param name="Port" value="42223" />
        <param name="RemoteHost" value="deb007vm" />
        <param name="ReconnectionDelay" value="60000" />
        <param name="Threshold" value="DEBUG" />
    </appender>
    <root>
        <priority value="debug"/>
        <appender-ref ref="socket"/>
    </root>
</log4j:configuration>

Here is my Dockerfile :

FROM logstash

    EXPOSE 4560

    COPY some/local/path/dockerTest.conf /logstash/conf/dockerTest.conf

    COPY some/local/path/patterns/* /logstash/conf/patterns/

    CMD ["-f", "/logstash/conf/dockerTest.conf"]

I run the docker image with the -p 42223:4560 flag.

My logstash configuration file looks like this :

input{
    log4j{}
}
filter{
    #some filters here
}
output{
    stdout{}
}

Could anyone help me with this?


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.