Configuring a Log Policy of an Application
ServiceStage allows you to configure application log policies for application components deployed in containers. You can view related logs on the AOM console.
You can configure log policies during component deployment. If no configuration is performed, the system collects standard application output logs by default.
Procedure
- Choose Advanced Settings > O&M Monitoring.
- On the Log Collection tab, click Add Log Policy and set the parameters by referring to the following table. Parameters marked with an asterisk (*) are mandatory.
Parameter
Description
Storage Type
Select a storage type.
- HostPath: Mount a host path to a specified container path.
- Mounting Path: Logs are exported only to the container path. You do not need to mount the host path.
*Host Path
This parameter is mandatory when Storage Type is set to HostPath.
Enter the log storage path on the host.
*Docker Mounting
- Set Mounting Path: Enter the application path to which the data volume is mounted.
NOTICE:
- Do not mount a data volume to a system directory such as / or /var/run. Otherwise, an exception occurs. An empty directory is recommended. If the directory is not empty, ensure that the directory does not contain any file that affects application startup. Otherwise, the files will be replaced, causing application startup exceptions. As a result, the application fails to be created.
- When the data volume is mounted to a high-risk directory, you are advised to use a low-permission account to start the application; otherwise, high-risk files on the host may be damaged.
- Set Extended Host Path. This parameter is mandatory when Storage Type is set to HostPath.
- None: No extended path is configured.
- PodUID: Pod ID.
- PodName: Pod name.
- PodUID/ContainerName: Pod ID or container name.
- PodName/ContainerName: Pod name or container name.
- Set Collection Path.
After specifying the collection path, you can specify the content to collect. The collection path can be specified if the ICAgent version of the collector is 5.12.22 or later. The following modes are supported:
- If no collection path is specified, log files in .log, .trace, and .out formats will be collected from the current path by default.
- If a collection path contains double asterisks (**), log files in .log, .trace, and .out formats will be collected from 5 levels of subdirectories.
- If a collection path contains an asterisk (*), a fuzzy match is performed.
Example: If the collection path is /tmp/**/test*.log, all .log files prefixed with test will be collected from /tmp and its 5 levels of subdirectories.
- Set Aging Period.
- Hourly: Log files are scanned every hour. If the size of a log file exceeds 20 MB, the system compresses the log file to a historical file, dumps the historical file to the directory where the log file is stored, and clears the original log file.
- Daily: Log files are scanned once a day. If the size of a log file exceeds 20 MB, the system compresses the log file to a historical file, dumps the historical file to the directory where the log file is stored, and clears the original log file.
- Weekly: Log files are scanned once a week. If the size of a log file exceeds 20 MB, the system compresses the log file to a historical file, dumps the historical file to the directory where the log file is stored, and clears the original log file.
- (Optional) Click to set Log Format.
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: The system collects logs based on the configured matching rules.
Log Segmentation: This parameter is mandatory when Log Format is set to Multi-line. It is used to match the beginning of each log. If you select Log Time, the time matching mode is used. If you select Regular pattern, 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.
Regularization: If Log Segmentation is set to Regular pattern, enter the regular expression based on the format of the beginning of each log.
After the component configuration and deployment are complete, you can view run logs on the AOM console. For details, see Viewing Log Files.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot