IPFS Logging configuration


I am trying to find the ipfs logs for content upload, download and the logs when an ipfs node in a cluster replicates the data to all other nodes.
I know we can check ipfs logs using ipfs log tail, but I can’t see logs having info for the operations I am looking for?

Also, can we configure all the logs to be written to a file just like ipfs cluster rest api.

Just use IPFS_LOGGING environment variable to set the level. The level set is standard: debug, info, warn, error, dpanic, panic, fatal. After setting of this variable, the daemon will throw the log messages of the selected level to stderr

1 Like

If you are using systemd service unit, there is the way to configure output for the logs inside .service file:

# It is possible also to set the output as a filestore: 'file:/var/log/<ipfs-log-file>' in systemd 2.36 or newer
1 Like

Thanks :+1: @twdragon

@twdragon , Thanks again.

I tried and was able to see the logs when I call the cluster API for adding content
http:// ipfs-node:9094/add

But for some reason, the logs are not generated when I try to get the data from gateway URL
http:// ipfs-node:8080/ipfs/filehash

any thoughts?

Did you try to turn logging to debug?

Yes, tried debug too.

I did set the env variable using export IPFS_LOGGING=debug but no logs were getting generated, so I tried ipfs log level all debug and I saw many logs populating.

Yet, logs for gateway api while fetching the data are still not generating.

Well, this is the mess. I can suggest you now only to examine the code which serves TCP in IPFS…

I had a quick look, and it may be that the gateway handlers are not logging much at all. I see no calls to around here log.Info/Debug(...)

I recommend opening a feature request in go-ipfs about better logging of gateway requests (please search for existing issues first around this topic).

Your best-shot workaround, however, is to put the IPFS gateway behind an nginx reverse proxy, which will log everything you want and let you control other stuff that IPFS does not allow to customize (max request body size, timeouts etc).