dockerloggingeclipse-ditto

Failed to get log files via volume in Eclipse Ditto


I was trying to save the logs of ditto locally and for that, I edited the ditto/deployment/docker/docker-compose.yml.The content of the same is:

   ... 

  gateway:
    image: docker.io/eclipse/ditto-gateway:${DITTO_VERSION:-latest}
    mem_limit: 512m
    restart: always
    networks:
      default:
        aliases:
          - ditto-cluster
    depends_on:
      - policies
    ports:
      - "8081:8080"
    environment:
      - TZ=Europe/Berlin
      - BIND_HOSTNAME=0.0.0.0
      - ENABLE_PRE_AUTHENTICATION=true
      # Set additional configuration options here appending JAVA_TOOL_OPTIONS: -Dditto.gateway.authentication.devops.password=foobar -Dditto.gateway...
      - JAVA_TOOL_OPTIONS=-XX:ActiveProcessorCount=2 -XX:+ExitOnOutOfMemoryError -XX:+UseContainerSupport -XX:+UseStringDeduplication -Xss512k -XX:MaxRAMPercentage=50 -XX:+UseG1GC -XX:MaxGCPauseMillis=150 -Dakka.coordinated-shutdown.exit-jvm=on -Dakka.cluster.shutdown-after-unsuccessful-join-seed-nodes=180s -Dakka.cluster.failure-detector.threshold=15.0 -Dakka.cluster.failure-detector.expected-response-after=10s -Dakka.cluster.failure-detector.acceptable-heartbeat-pause=20s -Dakka.cluster.downing-provider-class=
      # in order to write logs into a file you can enable this by setting the following env variable
      # the log file(s) can be found in /var/log/ditto directory on the host machine
      - DITTO_LOGGING_FILE_APPENDER=true
      # You may use the environment for setting the devops password
      #- DEVOPS_PASSWORD=foobar
    # only needed if DITTO_LOGGING_FILE_APPENDER is set
    # volumes:
      - ditto_log_files:/var/log/ditto
    healthcheck:
      test: curl --fail `hostname`:8558/alive || exit 1
      interval: 30s
      timeout: 15s
      retries: 4
      start_period: 120s

... 

volumes:
  ditto_log_files:
    driver: local
    driver_opts:
      type: none
      device: /var/log/ditto
      o: bind,uid=1000,gid=1000

Here, I just uncommented - DITTO_LOGGING_FILE_APPENDER=true and - ditto_log_files:/var/log/ditto, But still I am not getting anything in /var/log/ditto I want to solve the issue.


Solution

  • You did not uncomment

       # volumes:
    

    Which means that the volume is not recognized as such but interpreted as environment variable:

        # volumes:
          - ditto_log_files:/var/log/ditto
    

    So uncomment the # volumes: as well and you should get your logs via the mounted volume.