I
Immich•2y ago
grut

Saving logs to file?

I'm trying to save the containers logs to files (specifically the immich_server)... I was trying replacing the command in the docker file with something like
/bin/sh -c "mkdir -p /log &&
start.sh immich 2>&1 |
tee /log/immich_server.log"
/bin/sh -c "mkdir -p /log &&
start.sh immich 2>&1 |
tee /log/immich_server.log"
But the container won't start.. Any idea how i can do that?
4 Replies
bo0tzz
bo0tzz•2y ago
Docker already saves logs to a file by default, can you just use that? https://stackoverflow.com/a/35415274
Stack Overflow
Save docker-compose logs to a file
I have unit tests running on my build server and would like to capture the log results for analysis when something fails. I have yet to find a way to redirect the output of docker-compose logs to a...
grut
grutOP•2y ago
yes, i know that. the problem is that each time it restarts, the path changes and (in this case) crowdsec will be lost ^^ And it restart at least once a day for backing up... that's why im trying to save it in a know, fixed file 🙂
bo0tzz
bo0tzz•2y ago
I don't know crowdsec but from a quick google it seems like you might want https://docs.crowdsec.net/docs/data_sources/docker/ ?
Docker | CrowdSec
This module allows the Security Engine to acquire logs from running containers, in one-shot and streaming mode.
grut
grutOP•2y ago
i tried ^^ but ... for now, i can get it working (but i'm trying in parallel ^^). For now, it seems not reading the container logs... since i can fail login 40 times in a row ^^ but in the best world it's indeed what would be the best solution 🙂 OK i managed to fix my issue... Immich logs are colored, so there are escape chars everywhere... so the the line of logs (which was actually read by crowdsec, just not parsed) was not parsed correctly.. So i fixed my parser (that you can get in crowdsec hub if necessary 🙂 )

Did you find this page helpful?