Configure log collection

更新时间:
复制 MD 格式

When you create or deploy an application in a Container Service for Kubernetes (ACK) cluster, you can activate Simple Log Service (SLS). EDAS sends business file logs, container standard output (stdout), and standard error (stderr) logs to SLS. This lets you view logs without line limits and perform aggregation and analysis. This topic describes how to configure log collection.

Prerequisites

Configure log collection when you create an application

  1. Log on to the EDAS console. In the left-side navigation pane, choose Application Management > Applications. The Applications page appears. In the top navigation bar, select a region. In the upper part of the page, select a namespace. In the upper-left corner, click Create Application.

  2. In the Basic Information step, specify Cluster Type and Application Runtime Environment and click Next. The following table describes the parameters.

    Parameter

    Description

    Cluster Type

    The type of the cluster in which you want to deploy the application. Select Kubernetes Clusters.

    Application Runtime Environment

    The application runtime environment. Select an application runtime environment based on the type of the hosted application.

    • Java

      • Custom: Select this option if you want to use a custom image to deploy the application in a Kubernetes cluster.

      • Java: Select this option if you want to use a universal JAR package to deploy the application as a Dubbo or a Spring Boot application. You can set the Java Environment parameter after you select this option.

      • Tomcat: Select this option if you want to use a universal WAR package to deploy the application as a Dubbo or a Spring application. You can set the Java Environment and Container Version parameters after you select this option.

      • EDAS-Container (HSF): Select this option if you want to use a WAR or FatJar package to deploy the application as a High-speed Service Framework (HSF) application. You can set the Java Environment, Pandora Version, and Ali-Tomcat Version parameters after you select this option.

    • PHP: Select this option if the application is a PHP application that runs on Apache HTTP Server.

    • Node.js, C++, Go, and Other Languages: Select this option if you want to use a custom image to deploy the application in a Kubernetes cluster. The configuration process for multi-language applications is not described in this topic.

  3. In the Configurations step, configure the environment information, basic information, and deployment method for the application, set the related resource parameters, and then click Next.

  4. On the Advanced Settings page, expand Log Collection Settings, turn on Enable Log Collection to SLS, and configure the log collection parameters.

    设置日志收集

    Configuration Item

    Description

    Logstore Name

    Enter the name of the Logstore. If the Logstore does not exist, a new Logstore is created.

    Collection Log Type

    Select File Log (Path in Container) or Container Standard Output.

    Collection Path

    Enter the log path in the container. Example: /usr/local/tomcat/logs/catalina.*.log.

    Important
    • The log source path must include the log file name, such as /tmp0/cjsc.log.

    • Do not store other important files in the directory to prevent files from being overwritten.

    • To configure multiple collection rules, click Add Log Source.

  5. Click Create Application.

  6. On the Creation Completed page, check the information in the Basic Information, Configurations, and Advanced Settings sections. Then, click Create Application.

    In the upper part of the Application Overview page, click View Details. On the Change List page, view the application change process. Wait several minutes until the application is deployed. After the application change process is complete, view the status of the instance in the Basic Information section of the Application Overview page. If the status shows that a pod is running, the application is deployed.

Configure log collection when you update an application

If you did not configure log collection when you created the application, you can configure it when you update the application.

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, click Application Management > Applications. In the top navigation bar, select a region. In the upper part of the page, select a namespace. Select Container Service or Serverless Kubernetes Cluster from the Cluster Type drop-down list. Then, find the application that you want to deploy and click the application name.

  3. On the Overview or Basic information page, choose Deploy > Deploy in the upper-right corner.

  4. On the Select Deployment Mode page, select a deployment mode and click Start Deployment in the upper-right corner of the specified deployment mode section.

  5. Configure the environment and deployment package for the application. Expand Log Collection Settings, turn on Enable Log Collection to SLS, and configure the log collection parameters. Then, click OK.

    设置日志收集

    Configuration Item

    Description

    Logstore Name

    Enter the name of the Logstore. If the Logstore does not exist, a new Logstore is created.

    Collection Log Type

    Select File Log (Path in Container) or Container Standard Output.

    Collection Path

    Enter the log path in the container. Example: /usr/local/tomcat/logs/catalina.*.log.

    Important
    • After you click OK, the application restarts. Perform this operation during off-peak hours.

    • The log source path must include the log file name, such as /tmp0/cjsc.log.

    • Do not store other important files in the directory to prevent files from being overwritten.

Verify the result

After an application is deployed, EDAS collects logs and sends them to the specified Logstore based on the configured log collection rule.

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, click Application Management > Applications. In the top navigation bar, select a region. In the upper part of the page, select a namespace. Select Container Service or Serverless Kubernetes Cluster from the Cluster Type drop-down list. Then, find the application that you want to deploy and click the application name.

  3. In the navigation pane on the left, click Log Center, and then click the File Log (Collected by SLS) tab.

    On the File Log (Collected by SLS) tab, you can view the collected log information. If log data is present, log collection is configured successfully.

    • In the Operation column, click Redirect to query and analyze logs in the Simple Log Service console. For more information, see Query and analyze logs.

    • You can click Manage Log Source to open the Manage Log Source dialog box. In this dialog box, you can modify the Logstore name, or delete or add a log source.

FAQ

  • Does the EDAS logging feature support log rotation?

    EDAS supports wildcard characters for log rotation.

    Specify the name of the log file to be collected. The name is case-sensitive and can contain wildcard characters, such as *.log.

    The supported file name wildcard characters in Linux include *, ?, and [...].

  • What do I do if no data is displayed in the Simple Log Service console when I view file logs?

    By default, Simple Log Service queries data from the last 15 minutes. SLS does not collect content from files that were generated before you configured log collection. If no data is displayed in the Simple Log Service console, use a web shell to check whether your application is generating log files. If not, check your application.

DingTalk group for ACK and Serverless Kubernetes clusters

If you have questions or suggestions about using Container Service for Kubernetes (ACK) and Serverless Kubernetes clusters in EDAS, you can join the DingTalk group by searching for the ID 23197114 in DingTalk.