This topic describes how to use multiple Logtail configurations to collect logs from a log file.

By default, you can use only one Logtail configuration to collect logs from a log file. If you use multiple Logtail configurations to collect logs from a log file, only one Logtail configuration can be applied. If multiple Logtail configurations are applied, resources are consumed multiple times, and the performance of other services that are deployed on the same server as Logtail is affected. The resources include CPU, memory, disk I/O, and network I/O. We recommend that you do not use multiple Logtail configurations to collect logs from a log file.

If you want to store the same logs in different Logstores, you can use the data transformation feature of Log Service. The data transformation feature can replicate logs without affecting the performance of other services that are deployed on the same server as Logtail. For more information, see Replicate data from a Logstore.

If you want to use multiple Logtail configurations to collect logs from a log file, you can use one of the following methods:
  • Create a symbolic link for a directory

    Create a symbolic link for the directory in which the log file is stored. For example, if you want to use two Logtail configurations to collect logs from the /home/log/nginx/log/log.log file, you must run the following command to create a symbolic link that points to the directory of the file. Then, you can specify the real path in one Logtail configuration and specify the symbolic link in the other Logtail configuration.

    ln -s /home/log/nginx/log /home/log/nginx/link_log
  • Add settings in Logtail configurations to forcefully collect logs
    If you want to use multiple Logtail configurations to forcefully collect logs from a log file, you can add {"force_multiconfig": true} in the Advanced Options > More Configurations section of the Logtail configurations. logtail
  • Configure the startup parameters of Logtail

    If you want to use multiple Logtail configurations to collect logs from a log file, you can open the /usr/local/ilogtail/ilogtail_config.json file on the server on which Logtail is installed and add "accept_multi_config": true. For more information, see Configure the startup parameters of Logtail.