Log Level Setting
The log level can be set in the following ways:
- Set the log level in the command line.
You can log in to the development environment as the running user and run the global- or module-level log level setting command.
The adc command is available only when Toolkit is installed in the development environment and the following environment variable is set:
export PATH=/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/bin:$PATH
If GCC on the server that you have logged in to needs to be upgraded, run the gcc --version command to check the GCC version. If it is earlier than 7.3.0, upgrade GCC by referring to How Can I Install GCC 7.3.0? If the GCC has been upgraded, skip this step. After GCC is upgraded, set the environment variables and start the ada daemon process as follows:
export PATH=/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/tools/ide_daemon/bin:$PATH export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:{install_path}/lib64 nohup /usr/local/Ascend/driver/tools/ada &
In the preceding commands, replace {install_path} with the actual GCC 7.3.0 installation path, for example, /usr/local/gcc7.3.0/.
- /home/HwHiAiUser/Ascend/ascend-toolkit/latest is the default installation path in the development environment. This path is used as an example. You can replace it as required.
- To simplify operations, you can add the preceding environment variable to the user environment variable settings. You can use the Bash shell to modify ~/.bashrc and execute source ~/.bashrc for the modification to take effect, or modify /etc/profile and execute source /etc/profile. The environment variable does not need to be set again after reboot or re-login.
- You can also log in to the host-side server and run the global-level or module-level log setting command as the running user.
- If command not found is displayed when running the adc command, the possible cause is that there is no Toolkit installation. Install it by referring to CANN Software Installation Guide.
- If SSL connect error is displayed when running the adc command, the Port (defaults to 22118) may be prohibited by the firewall. Run the iptables -I INPUT -p tcp --dport 22118 -j ACCEPT command to enable it. After changing the log level, you are advised to prohibit the Port again using the iptables -I INPUT -p tcp --dport 22118 -j DROP command.
The command-line options for changing the log level are described as follows:
- HostIP: IP address of the host
- Port: port number (defaults to 22118), which must be consistent with that specified by HOST_PORT in the /home/HwHiAiUser/ide_daemon/ide_daemon.cfg file.
- level: log level, selected from ERROR, INFO, WARNING, DEBUG, and NULL (no log output).
- id: ID of the device whose log level is to be changed
- For Symmetric Multi-Processing (SMP): In an AI Server with 8 Ascend AI Processors, passing any digit from 0 to 3 sets the log levels of devices 0–3 at a time. Passing any digit from 4 to 7 sets the log levels of devices 4–7 at a time.
- For AMP: Log level of each device is set separately.
- To set the global log level, run the following command:
adc --host server IP address:port number--log 'SetLogLevel(0)[level]' --device id
Example: adc --host 192.168.1.2:22118 --log 'SetLogLevel(0)[info]' --device 0
- To set the module log level, run the following command:
adc --host server IP address:port number --log 'SetLogLevel(1)[moduleName:level]' --device id
Example: adc--host 192.168.1.2:22118 --log 'SetLogLevel(1)[TS:info]' --device 0
moduleName can be set to a module, such as slog or cce.
- To enable or disable event logs, run the following command:
adc --host server IP address:port number --log 'SetLogLevel(2)[enable/disable]' --device id
Example: adc--host 192.168.1.2:22118 --log 'SetLogLevel(2)[enable]' --device 0
enable: enables event logs.
disable: disables event logs.
- Set the log level in the configuration file.
For details about the configuration file, see Log Configuration File. After modifying the configuration file, run the reboot command to reboot the host system, or restart the slogd process.
After the log level is changed, if the Ascend AI Processor is restarted, the log level setting for the device side is restored to defaults.
- Set the log level using GLOBAL_LOG_LEVEL.
The log level set through the GLOBAL_LOG_LEVEL environment variable applies only to the global and module log level settings in the current shell, and will not change the configured value in slog.conf.
Set the log level using GLOBAL_LOG_LEVEL, parse the setting during the initialization of libslog.so, filter the log information based on the set value, and write the log information to the log file. If no value, or an invalid value is passed to GLOBAL_LOG_LEVEL, the global and module log levels set in slog.conf are used.
The following is an example:
export GLOBAL_LOG_LEVEL=1
GLOBAL_LOG_LEVEL can be set to:
- 0: DEBUG
- 1: INFO
- 2: WARNING
- 3: ERROR
- 4: NULL
- Other values: invalid