Log Configuration
Currently, log files can be configured in three ways: configuring new environment variables, configuring old environment variables, and configuring configuration files. The priorities are in descending order. Configuring old environment variables and configuration files will be unavailable in the future. You are advised to configure logs by configuring new environment variables. For details about how to configure logs by configuring new environment variables, see MindIE Log Reference.
- Configure new environment variables.
MindIE component names (mindie prefix omitted) [cert, ms, server, llm, sd]
Environment Variable
Default Configuration
Value Range and Description
MINDIE_LOG_LEVEL
INFO
Sets the log level of each MindIE component. The priority is higher than that of the MINDIEMS_LOG_LEVEL environment variable. If the environment variable is set, the log_level parameter in the JSON configuration file will be overwritten.
The log levels are [CRITICAL, ERROR, WARN, INFO, DEBUG].
MINDIE_LOG_TO_FILE
true
Sets whether to write logs of each MindIE component to a file. If the environment variable is set, the to_file parameter in the JSON configuration file will be overwritten.
The value range is [false, true] or [0, 1].
MINDIE_LOG_TO_STDOUT
false
Sets whether to print logs of each MindIE component. If the environment variable is set, the to_stdout parameter in the JSON configuration file will be overwritten.
The value range is [false, true] or [0, 1].
MINDIE_LOG_VERBOSE
true
Sets whether to add optional log content to logs of each MindIE component. Logs are classified into fixed log content and optional log content.
The complete debug log format is as follows: [Date time] [PID] [TID] [Component name] [Uppercase log level] [File:line] : [Error code] [*] Log message. The non-bold content is optional. When the environment variable is set to true, the optional content is added.
The value range is [false, true] or [0, 1].
NOTE:[*] in the log format indicates the name of a subcomponent or a small module. You can choose to display the name in logs to better locate faults.
MINDIE_LOG_PATH
~/mindie/log
Sets the directory for storing log files of each MindIE component.
If this environment variable is set, create the log/ directory in the path specified by this environment variable. The debug logs are recorded in the $MINDIE_LOG_PATH/log/debug directory, and the security logs are recorded in the $MINDIE_LOG_PATH/log/security directory by default.
- If the path starts with a slash (/), the path is an absolute path.
- If the path does not start with a slash (/), the path is a relative path, which is relative to ~/mindie/log.
- If the environment variable is set, the run_log_path and operation_log_path parameters in the JSON configuration file will be overwritten.
MINDIE_LOG_ROTATE
- -fs: The default value is 20 (MB).
- -r: The default value is 10.
Sets the log rotation of each MindIE component.
The format for rotating logs of a component: Component name: -fs filesize -r rotate
- If there is no component name before the colon (:), the log content of all components is set in a unified manner by default.
- filesize indicates the size of each log file (unit: MB). The value range is [1, 500]. If the environment variable is set, the max_log_file_size parameter in the JSON configuration file will be overwritten.
- rotate indicates the maximum number of log files that can be written by each process. The value range is [1, 64]. If the environment variable is set, the max_log_file_num parameter in the JSON configuration file will be overwritten.
Example 1: Set the log level of all MindIE components to debug and the log level of the cluster management component to info (the value entered by the user is case insensitive). export MINDIE_LOG_LEVEL=debug; ms:INfo Example 2: Set the log level of the MindIE LLM to error (the value entered by the user is case insensitive). export MINDIE_LOG_LEVEL=llm: error If the log level is null, the log function is disabled. Example 3: Set all MindIE components to print logs (the value entered by the user is case insensitive). export MINDIE_LOG_TO_STDOUT=1 Example 4: Write logs of all MindIE components to files (the value entered by the user is case insensitive). export MINDIE_LOG_TO_FILE=true Example 5: Do not print or save the optional logs of all MindIE components (the value entered by the user is case insensitive). export MINDIE_LOG_VERBOSE=false Example 6: Print or save the optional logs of the cluster management component (the value entered by the user is case insensitive). export MINDIE_LOG_VERBOSE=ms:true" Example 7: Set the directory for saving the cluster management component logs to /home/dev. export MINDIE_LOG_TO_FILE=ms:/home/dev Example 8: Set the rotation of the cluster management component. The maximum size of each file is 10 MB, and the maximum number of files for each process is 20. export MINDIE_LOG_ROTATE=ms:-fs 10 -r 20
In the same log configuration command, the latter configuration overwrites the former one. The log configurations are separated by semicolons (;) and imported one by one.
- Example 1: export MINDIE_LOG_LEVEL="llm: info; llm: warn" is equivalent to export MINDIE_LOG_LEVEL="llm: info"; export MINDIE_LOG_LEVEL="llm: warn" sets the log level of llm to warn. The latter configuration overwrites the former one.
- Example 2: export MINDIE_LOG_LEVEL="llm: info; warn" is equivalent to export MINDIE_LOG_LEVEL="llm: info"; export MINDIE_LOG_LEVEL="warn" sets the log level of llm to warn. The latter configuration overwrites the former one.
- Configure the old environment variable.
Environment Variable
Value Range and Description
MINDIEMS_LOG_LEVEL
NOTE:MINDIEMS_LOG_LEVEL is reserved for compatibility with the configuration mode of earlier versions.
If MINDIE_LOG_LEVEL is left blank, MINDIEMS_LOG_LEVEL is used.
You can dynamically set the level of logs generated by the cluster management component client.
The default value is empty. The priority of this environment variable is higher than that of the log_level parameter in the JSON configuration file. The log levels are as follows:
- DEBUG
- INFO
- WARNING
- ERROR
- CRITICAL
You can use the MINDIEMS_LOG_LEVEL environment variable to dynamically set the log printing level on the cluster management component client.export MINDIEMS_LOG_LEVEL={Log print level}- DEBUG
- INFO
- WARNING
- ERROR
- CRITICAL
- Configure the file.
- Client logs are filtered based on the log_level parameter configured in {$HOME}/.mindie_ms/msxxx.json and the log content is printed on the client screen.
- Server logs are set based on the following code in the server configuration file ms_xxx.json:
"log_info": { "log_level": "INFO", // Log level "run_log_path": "/var/log/mindie-ms/run/log.txt", // Path of the file to which run logs are written "operation_log_path": "/var/log/mindie-ms/operation/log.txt" // Path of the file to which operation logs are written "max_log_file_size": 20, // Maximum log file size "max_log_file_num": 10 // Maximum number of log files }
- After the logs are filtered based on levels, the log content is written to the log file in the log_path directory. If an error is reported on the server, you can locate the error based on the logs. The current log writing policy is cyclic writing. By default, up to 10 log files can be saved and the maximum size of each log file is 20 MB.
- When writing logs to log files, import the following environment variable on which KMC depends:
export HSECEASY_PATH=$MIES_INSTALL_PATH/lib
- If the service fails to start because the user configures the mandatory items in the configuration file incorrectly, the error log information is printed and saved to the default directory ~/mindie/log for fault locating.