Applications use logging frameworks, such as logback and log4j, to record logs. A log configuration file sets the log level and directs output to a file. Enterprise Distributed Application Service (EDAS) lets you modify log configurations at runtime, and the changes take effect immediately. In the EDAS console, you can create a log configuration, add content, and select the objects to which it will apply. You can also scrape an existing configuration. This topic describes how to configure dynamic logs.
Prerequisites
An ECS application is created. For more information, see Create and deploy an application in an ECS cluster.
The version of the Application Real-Time Monitoring Service (ARMS) agent mounted to the application is 2.9.0 or later.
NoteThe ARMS agent is mounted by default on applications that are created in EDAS. You can log on to an application instance and check the
/home/admin/.opt/ArmsAgent/versionfile to view the ARMS agent version.
Limits
This feature supports the following logging frameworks and configuration file formats:
log4j2: Supports XML, YAML, JSON, and Properties.
NoteFor YAML and JSON formats, the application must contain the required class libraries for the logging framework. If you are unsure, use XML.
logback: Supports XML.
You can use a complete log configuration file that includes any log level and output settings supported by the logging framework.
Applicable objects
ECS instances, application groups, and applications.
Create and enable a log configuration
-
Log on to the EDAS consoleEDAS console.
-
In the left-side navigation pane, choose . In the top navigation bar, select a region. In the upper part of the Applications page, select a microservices namespace from the Microservices Namespace drop-down list. Then, click the name of the application that you want to manage.
On the Basic Information page, choose Log Management > Log Configuration from the navigation pane on the left.
Based on the logging framework that your application uses, click Add Log Configuration. In the Add log4j2 Log Configuration or Add logback Log Configuration panel, configure the log information.
Enter a custom Log Name and description.
Set the Configuration Source:
Scrape from Application: Scrapes the original log configuration from an instance of the specified Running Application Version. The scraped configuration appears in the configuration content text box.
Custom: Paste your prepared configuration content directly into the configuration content text box.
Related operations
Enable: Applies the configuration to the selected target objects.
Disable: Deactivates the configuration. The enabled configuration with the next highest priority then takes effect. If no other configurations are enabled, the application's original log configuration is restored.
Restore Original Log Configuration: Automatically disables all configurations and restores the application's original log configuration.
FAQ
How do I restore the original log configuration?
Method 1:
On the Dynamic Log Configuration tab, click Restore Original Log Configuration.
Method 2:
In the log list under the log4j2 Log Framework or logback Log Framework section, click Disable in the Actions column for all log configurations.
If multiple configurations are enabled, which one takes effect?
The configuration with the highest priority takes effect. The priority order is: Instance > Application Group > Application.
How do I view the active log configuration for an instance?
Method 1:
After you enable a log configuration file, the content of the active configuration is recorded at the INFO log level. The logger name is
com.alibaba.agent.dynamic.log.config, as shown in the following figure.
NoteThe output location of this log content depends on the configuration of the
com.alibaba.agent.dynamic.log.configlogger.Method 2:
In the
/home/admin/.opt/ArmsAgent/path, find the file that starts with.applied. This file is the current active log configuration. If this file does not exist, the application's original log configuration is used.
If an application uses Groovy scripts or programmatic methods for log configuration, does EDAS support dynamic log configuration?
This is not supported.
If an enabled log configuration has a format issue, will logging fail?
If the log configuration file is enabled but the corresponding log frame is not configured, the application continues to use its original log configuration.
For the log4j2 framework, the YAML and JSON formats may not be effectively validated by the framework. This can cause unexpected results.
When scraping logs, can the log level configuration from Spring Boot be scraped?
Supported.