หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Configuring Log Collection

Updated on 2024-05-25 GMT+08:00

CAE provides log collection. Currently, logs can be collected only to LTS. You can configure the log collection path. In advanced settings, you can configure the log format (single-line (default) or multi-line).

This section uses Kafka as an example to describe how to customize log paths.
NOTICE:
  • If log files are mounted to system directories such as / and /var/run, components may not work. An empty directory is recommended. If the directory is not empty, ensure that the directory does not contain any file that affects component startup. Otherwise, the files will be replaced, causing component startup exceptions. As a result, the component fails to be created.
  • The log path must contain the log file name, for example, /var/log/test/error.log. To use a wildcard, you must also specify the extension, for example, /var/log/test/*.log, not /var/log/test/* or /var/log/test/*.*.
  • The log files must be text files.
  • By default, standard logs are collected for all components and are stored in the stdout file.
  • The log path must be different from the cloud storage configuration path.
  • An application in CAE maps to a log group in LTS. Creating a CAE application creates a log group.

Adding Log Collection

NOTE:

You can configure up to 20 log collection paths.

  1. Log in to CAE.
  2. Choose Component Configurations.
  3. Select the target component from the drop-down list in the upper part of the page.
  4. Click Edit in the Log Collection module.
  5. Click Add Log Path.
  6. Enter the path of the logs to be collected in Log Collection Path. For example: /var/log/springboot.log

    Figure 1 Configuring a log path

  7. Click Save.
  8. Configure advanced settings

    By default, the system collects and displays the logs printed by the program by line. If a complete log occupies multiple lines and you want to collect and display the entire log, you can set Log Format to enable multi-line logs.
    • Single-line: The system collects logs by line.
    • Multi-line: Multiple lines are merged into one line. The system collects logs by configured matching rules. The log lines that do not meet the matching rules will be merged with the lines that last met the matching rules.
      • If you select Log time, the time matching mode is used. If you select Regular expression, the regular expression matching mode is used.

        Time Wildcard: Enter the time wildcard when Log Segmentation is set to Log time.

        For example, if the time format of each log is YYYY-MM-DD hh:mm:ss, set the time wildcard to YYYY-MM-DD hh:mm:ss.

        Example time wildcard:

        YY   - year (19)
        YYYY - year (2019)
        M    - month (1)      
        MM   - month (01)
        D    - day (1) 
        DD   - day (01)
        hh   - hours (23)
        mm   - minutes (59)
        ss   - seconds (59) 
        SSS  - millisecond (999)
        hpm     - hours (03PM)
        h:mmpm    - hours:minutes (03:04PM) 
        h:mm:sspm  - hours:minutes:seconds (03:04:05PM)
        hh:mm:ss ZZZZ (16:05:06 +0100)
        hh:mm:ss ZZZ  (16:05:06 CET)   
        hh:mm:ss ZZ   (16:05:06 +01:00)
      • Regular expression: If Log Segmentation is set to Regular expression, enter the regular expression based on the format of the beginning of each log.

        Example regular expression:

        Example 1:

        19:41:33.217 [http-nio-8000-exec-1] ERROR o.a.c.c.C.[.[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException: Cannot invoke "com.example.springboothello.controller.HelloController.write()" because "helloController" is null] with root cause
        java.lang.NullPointerException: Cannot invoke "com.example.springboothello.controller.HelloController.write()" because "helloController" is null
        	at com.example.springboothello.controller.HelloController.nullPointException(HelloController.java:234)
        	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.base/java.lang.reflect.Method.invoke(Method.java:568)

        Regular expression for merging the preceding logs into one line: ^\d{2}:\d{2}:\d{2}.

        All lines that do not start with time are merged to the previous line.

        Example 2:

        Exception in thread "main" java.lang.IllegalStateException: A book has a null property
               at com.example.myproject.Author.getBookIds(Author.java:38)
               at com.example.myproject.Bootstrap.main(Bootstrap.java:14)
        Caused by: java.lang.NullPointerException
               at com.example.myproject.Book.getId(Book.java:22)
               at com.example.myproject.Author.getBookIds(Author.java:35)
               ... 1 more

        Regular expression for merging the preceding logs into one line: ^Exception.

        All lines that do not start with Exception are merged to the previous line.

        The page provides regular expression verification. You can copy the logs to Log Example, enter a regular expression, and click Verify to check whether the regular expression matches.

  9. Click OK.
  10. Make the configurations take effect.

    • If the component has been deployed, click Activate Settings in the upper part of the page. In the dialog box displayed on the right, confirm the configurations and click OK for the configurations to take effect.
    • If the component has not been deployed, click Set and Deploy Component in the upper part of the page. In the dialog box displayed on the right, click OK. After the deployment is complete, the configurations take effect.

      After the configurations take effect, you can view component logs in a specified path on the Component Logs page

Modifying a Log Path

  1. Log in to CAE.
  2. Choose Component Configurations.
  3. Select the target component from the drop-down list in the upper part of the page.
  4. Click Edit in the Log Collection module.
  5. Select the target path and click Edit in the Operation column.
  6. Reconfigure the log collection path, for example, /var/log/CAE/logs/*.out.

    Figure 2 Modifying a log path

  7. (Optional) Reconfigure the log collection format as required.
  8. Click Save and OK.
  9. Click Activate Settings in the upper part of the page. In the dialog box displayed on the right, confirm the configurations and click OK for the configurations to take effect.
  10. View the logs in the new path.

Deleting a Log Path

  1. Log in to CAE.
  2. Choose Component Configurations.
  3. Select the target component from the drop-down list in the upper part of the page.
  4. Click Edit in the Log Collection module.
  5. Select the target path and click Delete in the Operation column.
  6. In the displayed dialog box, click Yes. After deleting the path, click OK.

    Figure 3 Deleting a log path

  7. Click Activate Settings in the upper part of the page. In the dialog box displayed on the right, confirm the configurations and click OK for the configurations to take effect.

    NOTE:

    Deleted path files no longer collect logs. But you can still view the historical logs of the corresponding log file.

เราใช้คุกกี้เพื่อปรับปรุงไซต์และประสบการณ์การใช้ของคุณ การเรียกดูเว็บไซต์ของเราต่อแสดงว่าคุณยอมรับนโยบายคุกกี้ของเรา เรียนรู้เพิ่มเติม

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback