title: Does Fluentd support log rotation for file output?
body: <p>The current setup I am working with is a Docker compose stack with multiple containers. These containers send their logging information to a logging container (inside the compose stack) running the Fluentd daemon. The configuration for Fluentd consists of one <code>in_forward</code> source that collects the logs and writes them to separate files, depending on the container. My Fluentd configuration file looks similar to this:</p>
  
  <pre><code>&lt;source&gt;
    @type forward
    port 24224
    bind 0.0.0.0
  &lt;/source&gt;
  
  &lt;match container1&gt;
     @type copy
     &lt;store&gt;
       @type file
       path /fluentd/log/container1.*.log
       format single_value
       message_key "log"
     &lt;/store&gt;
  &lt;/match&gt;
  
  ...
  </code></pre>
  
  <p>My docker-compose.yml file looks something like this:</p>
  
  <pre><code>version: '3'
  
  services:
  
    container1:
      build: ./container1
      container_name: "container1" 
      depends_on:
       - "logger" 
      logging:
        driver: "fluentd"
        options:
          tag: container1  
      networks:
        static-net:
          ipv4_address: 172.28.0.4  
  
  
    ...
  
  
    logger:
      build: ./logger
      container_name: "logger"
      ports:
       - "24224:24224"
       - "24224:24224/udp"
      volumes:
       - ./logger/logs:/fluentd/log
      networks:
        static-net:
          ipv4_address: 172.28.0.5          
  
  networks:
    static-net:
      ipam:
        driver: default
        config:
         - subnet: 172.28.0.0/16
  </code></pre>
  
  <p>Everything works as expected, but I would ideally like to set Fluentd to keep a certain number of log files. I can change the size of the log files by configuring the <code>chunk_limit_size</code> parameter in a buffer section. However, even though I want this option, I still do not want Fluentd writing an endless amount of files. The <code>buffer_queue_limit</code> and <code>overflow_action</code> in the buffer configuration do not seem to affect anything. This application will be running continuously once deployed, so log rotation is a necessity. Several questions I have:</p>
  
  <ol>
  <li>Does Fluentd support log rotation for writing logs to files? If so, what parameters do I set in the Fluentd configuration file?</li>
  <li>If not, can I configure Docker in such a way that I can utilize its log rotation of the json logging driver for Fluentd?</li>
  <li>And if that is not possible, is there a way to add log rotation into Fluentd via a plugin or perhaps in the Fluentd docker container itself (or a sidecar container)?</li>
  </ol>