#Docker Compose Not Displaying Logs for Java Application

1 messages · Page 1 of 1 (latest)

rotund orchid
#

I am currently facing an issue with my Docker Compose setup for a Java application. The application runs successfully locally, and I can see logs when executed outside Docker. However, when I run it using Docker Compose, the logs are not being displayed for each service.. Any insights or suggestions on how to troubleshoot and resolve this issue would be greatly appreciated! I've provided the relevant snippets of my Docker Compose file, Dockerfile, and Java application code for reference.

dark graniteBOT
#

<@&987246399047479336> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

output in the console. However, when I run the application using Docker Compose, I am not able to see any logs.

Here are a few things you can check to troubleshoot this issue:

  1. Check the logging configuration: Make sure that the logging configuration for your Java application is properly set up. This includes checking the log levels and log file locations. You can also try changing the log level to a higher value (e.g., DEBUG) to see if more logs are displayed.

  2. Verify the Docker Compose configuration: Ensure that your Docker Compose file is correctly configured to capture and display logs. In your service definition, make sure you have set logging options such as driver and options. For example:

#
   services:
     myapp:
       ...
       logging:
         driver: "json-file"
         options:
           max-size: "10m"
           max-file: "3"
#

This example configures the logging driver as json-file and sets options for maximum log file size and number of files.

  1. Check container logs: Docker Compose captures container logs by default, so you can try viewing them using the following command:
#
   docker-compose logs <service-name>
#

Replace <service-name> with the name of your service defined in Docker Compose.

  1. Enable stdout/stderr logging: By default, Docker captures container output from stdout/stderr and displays it in real-time when running in interactive mode (docker-compose up). However, if you are running Docker Compose in detached mode (docker-compose up -d), you may need to explicitly enable stdout/stderr logging by adding -f flag:
#
   docker-compose logs -f <service-name>
#
  1. Verify application startup: Ensure that your Java application is starting correctly inside the container. Check if any error messages are displayed during the startup process. You can also try running the container in interactive mode (docker-compose up) to see if any error messages are printed to the console.

By following these steps, you should be able to troubleshoot and resolve the issue with Docker Compose not displaying logs for your Java application.

rotund orchid
#

the docker compose:

#

not sure if the main is beeing runed,,bcs I dont even see the first print in the main;

fast dirge
#

What does docker logs show

rotund orchid
#

em nothing:

rotund orchid
fast dirge
#

What's in your docker file

rotund orchid
#

i have this

fast dirge
#

What happens if you run that java command in your terminal

rotund orchid
#

sorry what command

fast dirge
#

Line 15

rotund orchid
#

i did this but also nothing happend:

fast dirge
#

There's your problem

#

The command you're telling docker to run doesn't work so change it 🙂

rotund orchid
#

em okey..what should be the correct one

fast dirge
#

Well the command you're running looks different to the one in the docker file

#

But the effect is the same, your jar looks broken

#

Try rebuilding your jar

rotund orchid
#

I see now the first print:

#

but doing docker-compose :

fast dirge
#

well java --class-path

#

Is that the same as the command you're running?

#

The command is java -jar not whatever you're running in docker

rotund orchid
#

chenged it but still:

rotund orchid
#

.

rotund orchid
#

up

fast dirge
#

delete the container and try again

#

it might be that the old jar is still there