I have a django application that runs in a docker container. I have a defaults.py file which defines the LOGGING configurations, i have included a file handler in the logging configuration to log to files.
‘file’: {‘class’: ‘logging.FileHandler’,
‘filename’: ‘/opt/tejcli/release/log/temp.log’,
‘formatter’: ‘simple’},
Above piece of code is the file handler that i have included. Unfortunately no logs are being written to the temp.log and not even a file is being created. I have manually created the tejcli/release/log folders. I wrote a python script and put it in home directory and tried writing logs to the same folder and it works. How do i solve this?
Are you trying to write this log file to the opt directory in the container or in the host?
If on the host, are the proper permissions set for the uid being used in the container to write that log file on the host? Check syslog in addition to the docker logs on the host for possible error messages being shown.
If it’s writing inside the container, how are you checking for that file? (And, the same permissions question applies.)
Actually the issue is solved but for everyone’s clarification:
I have entered the docker container using bash and container id, I am new to docker so please excuse my terminologies. Inside the docker container is a file system and there is an opt directory just like the linux local file system, and the file path that i have mentioned is in that docker file system and the logs are getting created there. Later I have put the file path in the docker-compose.yml.j2 file and the logs started to store in the local file system.