为 zookeeper 更改 log4j.properties 的路径

change the path of the log4j.properties for zookeeper

我想为 zookeeper 更改 log4j.properties 文件的路径,因为我也想从中央配置文件夹中读取此配置文件,但我还没有找到有关如何执行此操作的任何信息。

这就是我启动 zookeeper 的方式:

/bin/zkServer.sh start /zoo.cfg

哪里

我现在做的是一个愚蠢的解决方案:

有没有更好的方法来配置外部 log4j.properties 文件的使用?

这里我假设您使用

提供的 Zookeeper(及其脚本)

启动zookeeper前需要导出一个变量

这里是默认值

if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
    export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/log4j.properties"
fi

所以,你需要做

export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/path/to/your.properties"
zookeeper-server-start zoo.cfg &

最好将它们一起重构为 systemctl 服务,不过