You can choose Log > HiLog to view the real-time logs of all apps on a device. The default log information displayed in the HiLog window contains the following:
Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 |
|---|---|---|---|---|---|
Timestamp of the log. | Process ID and thread ID. | Service domain and tag of the log. | Application bundle name. | Level of the log. | Content of the log. |
You can filter logs by app bundle name, log level, and keyword, customize the log display format, export logs, and display the latest logs.
The buttons on the left of the HiLog window are described as follows:
: goes to the previous page and stops automatic scrolling of the log window.
: goes to the next page and stops automatic scrolling of the log window. If the log window has reached the bottom, it automatically scrolls.
: adds line feeds when necessary. If this icon is not selected, logs are displayed line by line.
: automatically scrolls logs to the bottom of the window. If this icon is not selected, the window stays at the current log.
: starts reloading logs from the device log buffer.
: clears the device cache and HiLog window logs.
: takes a screenshot of the selected device and saves it locally.
: records the screen of the selected device and saves the recording locally.
: saves cached logs to a specified file for online logs, or to save the logs as an offline log file.
: automatically selects and switches connected devices.
: switches the log view and customizes the log display format.
: closes the current log window.
: goes to the online help document related to HiLog.
Enter the keyword in the HiLog search box. All logs containing the keyword are displayed.
You can click
to enable or disable case sensitivity for filtering, click
to enable or disable regular expression matching for filtering, and click
to enable or disable keyword highlighting.

Since DevEco Studio 6.0.2 Beta1, you can use the logical operator & to concatenate multiple keywords for precise log searching. Note that spaces must be included before and after the & character.

You can use the options provided by HiLog to filter logs.

When All logs of selected app or User logs of selected app is selected, you can select a process from the process drop-down box.
If USB debugging is not enabled when the device starts, some system apps may not register properly, and the HiLog list will not display these unregistered system apps. To view the logs from these apps, you can filter logs by keywords in HiLog or keep USB debugging enabled and restart the device.

You can also enter a PID or a keyword of the app name in the process drop-down box to search for the process to be filtered.

HiLog provides logs of the following levels: Debug, Info, Warn, Error, and Fatal. You can specify the log level to filter, and the system displays logs of the specified level and higher levels.

For example, if you select the Warn level, logs of the Warn, Error, and Fatal levels are displayed.

Since version 26.0.0, logs can be filtered by log tag. Multiple tags are supported and separated by commas (,). If a tag contains special characters, enclose the tag in quotation marks ("").

In addition to default filtering options, HiLog also allows you to customize and save filtering options for reuse.
To customize a filtering option, select Config custom filter.

In addition to the filtering options described above, you can configure the following:

After the configuration, the custom filtering option configured is automatically applied.

Now, the logs are filtered based on the specified keyword, log level, and custom filtering option.
You can customize the log display format to filter out unnecessary information.
Click
on the left, and set the log display format as required:

Customize the log display format in Hilog Format.
Format: To display date and time, select Datetime; to display time only, select Time.
include thread id: To display the thread ID, select this option.
Show domains: To display the domain, select this option.
Show processnames: To display the process name, select this option.
Show tags: To display the tag, select this option.
Total column width: Set the maximum width of the domain/processname/tags column. Excessively long information will be abbreviated in the column and displayed in full via a tooltip.
Package column width: Set the maximum width of the bundle name column. If the bundle name exceeds the maximum column width, complete bundle name is displayed in a tooltip.

If a log message cannot be displayed completely in the log window, you need to drag the scroll bar to view the log message. To wrap lines, click
Soft-Wrap.


HiLog displays logs in real time, with the newest entries appearing at the bottom of the window. To enable the view to automatically navigate to the latest logs, click
Scroll to End. To stop the automatic scrolling and stay on the current line, just click on the HiLog window.

You can save the filtered logs to a local file for further analysis.
Click
Export HiLog. In the Export HiLog To dialog box, specify the directory for saving the logs.

There are two log-related buffers: device log buffer and HiLog console buffer (buffer of the HiLog window).
The process for printing logs on HiLog is as follows:
To clear logs, click
Clear All. The device log buffer and HiLog window buffer, as well as the logs that have been printed, are cleared. Then, the HiLog window displays the logs that are newly output to the device log buffer after the clear operation.

The logs displayed in the HiLog window are stored in the console buffer. The buffer size determines the maximum number of logs that can be displayed in this window. When the number of logs reaches the maximum, the earliest logs will be automatically cleared. You can set the size of the HiLog console buffer.
Choose Settings > Buffer. The buffer settings window is displayed.

Select Override console cycle buffer size and enter the buffer size. The default buffer size is 4096 KB. If you change the buffer size, restart the HiLog window for the change to take effect.

To restart the HiLog window, click the
button in the lower part and then choose
> Online Log in the upper part.

When the number of logs reaches the maximum, the earlier logs displayed in the upper part of the window are continuously cleared and keeps scrolling. To view the log information, right-click in the window and choose Pause Output from the shortcut menu to pause log printing. After viewing the log information, deselect Pause Output to resume log printing.

To view the size of the device log buffer, run the hdc shell hilog -g command. The default buffer size is 256 KB.

To change the log buffer size, run the hdc shell hilog -G command.

To set the buffer size for a certain type of logs, run the hdc shell hilog -G command with the parameter -t.

Once the maximum device buffer size is reached, historical logs are saved to the data/log/hilog directory of the device. You can download historical logs from this directory for log analysis.
In DevEco Studio, you can view offline device logs located at /data/log/hilog from the offline log window, which displays the logs after they have been parsed and formatted.
Click New in the upper left corner of the HiLog window, and then click Offline Log to open the offline log window.

The offline log window provides the same functionality as the online log window, except that the device drop-down list box only supports the selection of real devices and emulators.

Offline logs can be filtered by time, with the default time range being the 30 minutes before the window is opened. In addition to the displayed format, you can also enter time in yyyyMMddHHmm format.

After you enter the time, the log file list will refresh, and clicking a file will download it from the device and automatically parse and output it to the offline log window.
The content of the latest log file continues to be updated until it reaches the specified size. If you reopen the offline log window or change the time setting, the list of logs refreshes, leading to the download and parsing of additional content from the latest log file.
You can set the amount of text that can be output in the offline log window by referring to Setting the HiLog Console Buffer Size. If the value is set too small, not all logs of the selected file can be displayed. The recommended buffer size is 6 MB (6144 KB).
If the complete logs cannot be displayed due to the buffer size limit of the window, click the Save button in the left toolbar to export offline logs. The exported file contains the original parsed logs that are not formatted by DevEco Studio, so you can view the complete logs.
