flink docker中的日志文件

bqf10yzr  于 2021-06-25  发布在  Flink
关注(0)|答案(1)|浏览(602)

我在使用flink-1.4.0 docker,比如:

version: '3'
services:
  jobmanager:
    image: ${FLINK_DOCKER_IMAGE_NAME:-flink}
    expose:
      - "6123"
    ports:
      - "8081:8081"
    command: jobmanager
    volumes:
      - /home/yeyunlong/work/flink/flink-jar:/var/log/mongodb
    environment:
      - JOB_MANAGER_RPC_ADDRESS=jobmanager

  taskmanager:
    image: ${FLINK_DOCKER_IMAGE_NAME:-flink}
    expose:
      - "6121"
      - "6122"
    depends_on:
      - jobmanager
    command: taskmanager
    links:
      - "jobmanager:jobmanager"
    environment:
      - JOB_MANAGER_RPC_ADDRESS=jobmanager

在docker中,dir/opt/flink/log为空。但是使用 docker logs $(containerId) ,我可以得到所有的日志信息。
我应该怎么做才能登录 /opt/flink/log . 谢谢您!

bvjveswy

bvjveswy1#

我正在使用docker flink images,它使用bin/flink-console.sh启动jm或tm。该脚本依赖于conf/log4j-console.properties中的设置。
我使用下面的docker-compose.yaml来设置我自己版本的log4j属性文件。从docker-compose.yaml中,我可以设置要使用的文件,并从log4j的属性文件控制输出。

version: "2.1"

services:
  jobmanager:
    image: flink
    expose:
      - "6123"
    ports:
      - "8081:8081"
    command: jobmanager
    volumes:
      - /c/Users/XYZ/playground/flink/shared/log4j.properties:/opt/flink/conf/log4j-console.properties
    environment:
      - JOB_MANAGER_RPC_ADDRESS=jobmanager
      - FLINK_ENV_JAVA_OPTS=-Dlog.file=/opt/flink/log/jobmanager.log

  taskmanager:
    image: flink
    expose:
      - "6121"
      - "6122"
    depends_on:
      - jobmanager
    command: taskmanager
    links:
      - jobmanager:jobmanager
    volumes:
      - /c/Users/XYZ/playground/flink/shared/log4j.properties:/opt/flink/conf/log4j-console.properties
    environment:
      - JOB_MANAGER_RPC_ADDRESS=jobmanager
      - FLINK_ENV_JAVA_OPTS=-Dlog.file=/opt/flink/log/taskmanager.log

相关问题