You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Shannon Lloyd <sh...@gmail.com> on 2015/01/15 07:19:57 UTC

Configuring location for server (log4j) logs

By default Kafka writes its server logs into a "logs" directory underneath
the installation root. I'm trying to override this to get it to write logs
to an external location so that I can separate all the read/write logs/data
from the read-only binaries. But I can't get it to work correctly.

I've set the following in my startup script to try to get it to log to
/data/kafka/log:

export
KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/etc/kafka/log4j.properties
-Dkafka.logs.dir=/data/kafka/log"

In /etc/kafka/log4j.properties I've also set kafka.logs.dir to the same
location as specified above. If I only specify it in the properties file
and not via KAFKA_LOG4J_OPTS, it doesn't work (all of the logs keep going
to the default location).

And this works... sort of. It sends all logs where I want *except* for
kafkaServer-gc.log and kafkaServer.out, both of which still go to "logs"
under the installation root.

Am I missing something? Or can I simply not redirect these two files so
that ALL my logs go somewhere outside the installation location?

Thanks.

Re: Configuring location for server (log4j) logs

Posted by Manikumar Reddy <ku...@nmsworks.co.in>.
you just need to set LOG_DIR property . All logs will be redirected to
LOG_DIR directory.

On Thu, Jan 15, 2015 at 11:49 AM, Shannon Lloyd <sh...@gmail.com> wrote:

> By default Kafka writes its server logs into a "logs" directory underneath
> the installation root. I'm trying to override this to get it to write logs
> to an external location so that I can separate all the read/write logs/data
> from the read-only binaries. But I can't get it to work correctly.
>
> I've set the following in my startup script to try to get it to log to
> /data/kafka/log:
>
> export
> KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/etc/kafka/log4j.properties
> -Dkafka.logs.dir=/data/kafka/log"
>
> In /etc/kafka/log4j.properties I've also set kafka.logs.dir to the same
> location as specified above. If I only specify it in the properties file
> and not via KAFKA_LOG4J_OPTS, it doesn't work (all of the logs keep going
> to the default location).
>
> And this works... sort of. It sends all logs where I want *except* for
> kafkaServer-gc.log and kafkaServer.out, both of which still go to "logs"
> under the installation root.
>
> Am I missing something? Or can I simply not redirect these two files so
> that ALL my logs go somewhere outside the installation location?
>
> Thanks.
>