1

Some of my modules have very verbose logging, and the logfiles are getting quite big.

Is there a way to specify a rolling file appender to limit the logfiles to a specific size?

2 Answers2

1

Yes, you can use the standard docker config options for this. Here was recently posted an example: https://github.com/Azure/iotedge/issues/650#issuecomment-476033302

"createOptions": {
    "HostConfig": {
        "LogConfig": {
            "Type": "json-file",
            "Config": {
                "max-size": "5m",
                "max-file": "2"
            }
        }
    }
}

This will limit the log file size to 5MB and 2 files.

silent
  • 14,494
  • 4
  • 46
  • 86
1

If you don't want to do the settings separately for all modules you can also create a file /etc/docker/daemon.json with the following content:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "5m",
    "max-file": "2"
  }
}

You then have to restart docker with sudo systemctl restart docker.

René
  • 3,413
  • 2
  • 20
  • 34