# Link log4j to a logstash docker image

**URL:** <https://discuss.elastic.co/t/link-log4j-to-a-logstash-docker-image/69207>\
**Category:** Logstash\
**Created:** [December 15, 2016, 6:33pm UTC](https://discuss.elastic.co/t/link-log4j-to-a-logstash-docker-image/69207 "2016-12-15T18:33:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ImInLoveWithCacao](https://avatars.discourse-cdn.com/v4/letter/i/e19adc/32.png) [@ImInLoveWithCacao](https://discuss.elastic.co/u/ImInLoveWithCacao)\
**Post date:** [December 15, 2016, 6:33pm UTC](https://discuss.elastic.co/t/link-log4j-to-a-logstash-docker-image/69207/1 "2016-12-15T18:33:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 12, 2017, 6:33pm UTC](https://discuss.elastic.co/t/link-log4j-to-a-logstash-docker-image/69207/2 "2017-01-12T18:33:47Z")

</div>

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