Move log file(s) to log-directory?
jsassner opened this issue · comments
I'm on v1.8.27, running it in docker not connected to HA (i run OpenHab).
I want to have linux rsyslog read the log file and notify my syslog server with errors, and today i do that by binding the volvo2mqtt.log log file that resides in the main directory. That log file just wrapped around (> 100kb in size) and i ran into docker issues mapping that 2nd file.
Any chance you can move the log file to a local directory (like "log" in the main directory) i can bind to instead of binding to the file?
Permission issue with the bind mount?
I'd rather avoid:
volumes:
- type: bind
source: ./logs/volvo2mqtt.log
target: /volvoAAOS2mqtt/volvo2mqtt.log
- type: bind
source: ./logs/volvo2mqtt.log.1
target: /volvoAAOS2mqtt/volvo2mqtt.log.1
- type: bind
source: ./logs/volvo2mqtt.log.2
target: /volvoAAOS2mqtt/volvo2mqtt.log.2
- type: bind
source: ./logs/volvo2mqtt.log.3
target: /volvoAAOS2mqtt/volvo2mqtt.log.3
....
is it a permissions issue with access to the directory you've mapped volvo2mqtt.log
too?
No, logging to volvo2mqtt.log works.
It was some time since i got the error, so can't remember exactly what error i got. But it was when volvo2mqtt.log was full (100k) and was gonna be moved to volvo2mqtt.log.1 and a new volvo2mqtt.log created.
So then i thought: "why do i have to map each file, can't they be put in a log directory instead?"
can the docker container create a new file or does it not have write permissions?
what does your docker-compose.yml look?
- type: bind
source: ./logs/volvo2mqtt.log
target: /volvoAAOS2mqtt/volvo2mqtt.log
- type: bind
source: ./logs/volvo2mqtt.log.1
target: /volvoAAOS2mqtt/volvo2mqtt.log.1
- type: bind
source: ./logs/volvo2mqtt.log.2
target: /volvoAAOS2mqtt/volvo2mqtt.log.2
- type: bind
source: ./logs/volvo2mqtt.log.3
target: /volvoAAOS2mqtt/volvo2mqtt.log.3
But i'd rather have this:
volumes:
- type: bind
source: ./logs/
target: /volvoAAOS2mqtt/logs/
i.e. i don't want to single-bind a log file. This ticket isn't about write permission, it's about log dir structure.
Looks like if you run this as a Home Assistant addon you do get the log in /logs
Line 44 in 907440b
I'm not sure why ypu can't just do?
- type: bind
source: ./logs/volvo2mqtt.log
target: /volvoAAOS2mqtt/
I do not run HomeAssistant (see first post).
Never bound a container file to a host directory. But no matter if it works or not, it will still force me to bind each and every log file in the docker-compose file.
Never bound a container file to a host directory. But no matter if it works or not, it will still force me to bind each and every log file in the docker-compose file.
I'm not sure why it would require you to create every file if the container had the correct host permissions but I don't feel that I have anything else to add.
Good luck.
Please bind every single file. It will work and you don't even need five versions from the log, in my opinion.