You can activate Log Service. Then, Enterprise Distributed Application Service (EDAS) can store business logs and container standard output (stdout) and standard error (stderr) logs to Log Service. In this way, you can view logs without limits on the number of lines and perform automatic aggregation and analysis on these logs.

Prerequisites

  • Log Service is activated. For more information, see Activate Log Service.
  • Ensure that a 0.25-core CPU and 250 MB memory are reserved for each instance in your application.

Configure log collection when you create an application

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. On the Applications page, select a namespace in the upper part and click Create Application in the upper-left corner.
  3. In the Basic Information step, specify Cluster Type and Application Runtime Environment, and click Next.
    Parameter Description
    Cluster Type Select Kubernetes Clusters.
    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 specify 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 specify 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 specify the Java Environment, Pandora Version, and Ali-Tomcat Version parameters after you select this option.
    • PHP: Select this option if you want to run this application as a PHP application 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. For more information, see Use custom images to deploy applications of different programming languages in Kubernetes clusters.
  4. In the Configurations step, configure the environment information, basic information, deployment method, and resource parameters for the application, and click Next.
  5. In the Advanced Settings step, click Log Collection Settings, turn on Enable log collection to SLS, and set log collection information as needed.
    Configure log collection
    Parameter Description
    Logstore Name Enter the name of the Logstore. If the Logstore does not exist, a new Logstore is created.
    Collection Log Type You can select File Logs (Log Path in the Container) or Standard Output Logs of the Container.
    Collection Path Enter the log path in the container, for example, /usr/local/tomcat/logs/catalina.*.log.
    Notice
    • The name of the directory for storing log sources must contain the log file name, for example, /tmp0/cjsc.log.
    • To prevent the files in the directory for storing log sources from being overwritten, do not store other important files in the directory.
    • To configure multiple collection rules, click Add Log Source.
  6. Click Create Application.
  7. In the Creation Completed step, confirm the settings in Basic Information, Configurations, and Advanced Settings, and click Create Application.
    In the upper part of the Application Overview page, click View Details. On the Change List page, you can view the change process. Wait a few minutes until the application is deployed. After the change process is complete, view the running status of the instances in the Basic Information section of the Application Overview page. If the pod that runs the application is in the running state, the application is deployed.

Configure log collection when you update an application

If you do not specify log collection settings when you create an application, you can specify them when you deploy the application.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. On the Applications page, select a namespace in the upper part, and 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 Application 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 application environment and deployment package information. In the Advanced Application Settings step, click Log Collection Settings. Turn on Enable log collection to SLS, and then configure log collection as needed. Click OK.
    Configure log collection
    Parameter Description
    Logstore Name Enter the name of the Logstore. If the Logstore does not exist, a new Logstore is created.
    Collection Log Type You can select File Logs (Log Path in the Container) or Standard Output Logs of the Container.
    Collection Path Enter the log path in the container, for example, /usr/local/tomcat/logs/catalina.*.log.
    Notice
    • The application is restarted after you click OK. We recommend that you perform this operation during off-peak hours.
    • The name of the directory for storing log sources must contain the log file name, for example, /tmp0/cjsc.log.
    • To prevent the files in the directory for storing log sources from being overwritten, do not store other important files in the directory.

Verify the result

After an application is deployed, EDAS collects logs and saves the logs in the specified files based on the configured log collection rule.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. On the Applications page, select a namespace in the upper part, and 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 left-side navigation pane, click Logs. On the page that appears, click the File Logs tab.
    On the File Logs tab, view the collected log information. If logs appear on the tab, log collection is configured.
    • You can click Go in the Actions column to query and analyze logs in the Log Service console. For more information, see Query and analyze logs.
    • You can click Manage Log Source. In the Manage Log Source dialog box, modify the LogStore Name parameter and add or delete log sources.

FAQ

  • Does the logging feature of EDAS support log rolling?

    Yes. EDAS allows you to roll logs by using wildcards.

    Specify the name of the log file to be collected. The name is case-sensitive and can contain wildcards. For example, you can specify *.log.

    The file name wildcards in Linux include asterisks (*), question marks (?),and [...].

  • What can I do if no data appears in the Log Service console when I query the file logs?

    By default, Log Service returns the query results of the last 15 minutes and does not collect the logs that are generated before log collection is configured. If no data appears in the Log Service console, we recommend that you use a webshell to check whether logs are generated for your application.

    • If logs are generated, submit a ticket. For more information, see Submit a ticket.
    • If no logs are generated, check your application health status.