• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. User Guide 2.0
  4. Log Management
  5. Collecting Logs in a Specified Path of a Container

Collecting Logs in a Specified Path of a Container

Procedure

  1. When creating a containerized application, upload an image in Set Containers and select Log Policies.
  2. Click Add Log Policy. Set the parameters for configuring a log policy based on application requirements. The following uses an nginx application as an example.

    Figure 1 Adding a log policy
    Table 1 Parameters for adding a log policy

    Parameter

    Description

    Storage Type

    Currently, only HostPath is supported.

    * Host Path

    Enter the log storage path on the host.

    Add Container Path

    Container Path

    1. Click Add Container Path.
    2. Enter the container path to which the data volume is mounted.
      NOTICE:
      • Do not mount a data volume to a system directory such as / or /var/run. This action may cause a container error to occur. You are advised to mount the data volume to an empty directory. If the directory is not empty, ensure that the directory does not contain any files that affect container startup; otherwise, the files will be replaced, making it impossible for the container to be properly started. The application creation will fail.
      • When the data volume is mounted to a high-risk directory, you are advised to use a low-permission account to start the container; otherwise, high-risk files on the host machine may be damaged.

    Extended Host Path

    None: No extended path is configured.

    Aging Period

    • Hourly: Log files are scanned every hour. If a log file exceeds 20 MB, it will be dumped to a historical file in the directory where the log file is saved and then will be cleared.
    • Daily: Log files are scanned every day. If a log file exceeds 20 MB, it will be dumped to a historical file in the directory where the log file is saved and then will be cleared.
    • Weekly: Log files are scanned every week. If a log file exceeds 20 MB, it will be dumped to a historical file in the directory where the log file is saved and then will be cleared.

  3. Click OK. An application is created.
  4. View logs.

    After the application is created, access the nginx application. On the Application O&M tab, select All instances.