1# DFX Development 2 3 4## How do I flush HiLog information to disks? (API 9) 5 6**Solution** 7 8Run the **hilog -w start -f ckTest -l 1M -n 5 -m zlib -j 11** command. 9 10The log file is saved in the **/data/log/hilog/** directory. 11 12**Parameters:** 13 14``` 15-**-w**: Starts a log flushing task. **start** means to start the task, and **stop** means to stop the task. 16-**-f**: Sets the log file name. 17-**-l**: Sets the size of a single log file. The unit can be B, KB, MB, or GB. 18-**-n**: Sets the maximum number of log files. When the number of log files exceeds the specified value, the earliest log file will be overwritten. The value range is [2,1000]. 19-**-m**: Specifies the log file compression algorithm. 20-**-j**: Specifies the task ID. The value ranges from **10** to **0xffffffffff**. 21For more details about parameters, run the **hilog --help** command. 22``` 23 24 25## How do I print only HiLog information of the current application? (API 9) 26 27**Solution** 28 29Use the hilog command line tool to filter the logs of the current application. 30 31**hilog -T xxx**: filtering logs by tag. 32 33**hilog –D xxx**: filtering logs by domain. 34 35**hilog -e**: matching log content based on the tag, domain, and pid by using regular expressions. Multi-layered filtering, combination filtering, and reverse filtering are supported. 36 37 38## How do I locate the fault when the application crashes? (API 9) 39 40**Solution** 41 42Method 1: Locate the crash-related code based on the service log. 43 44Method 2: View the error information in the crash file. The crash file is located at **/data/log/faultlog/faultlogger/**. 45 46 47## Is HiLog or console recommended for log printing? How do I set the domain if HiLog is used? (API 9) 48 49The console encapsulates the HiLog system with the default parameter configuration. It is mainly used in the application development and debugging phase. 50 51HiLog is recommended because it supports log classification and processing in a unified manner. For details, see [@ohos.hilog (HiLog)](../reference/apis/js-apis-hilog.md). 52 53The value of the **domain** parameter in the HiLog API ranges from **0x0** to **0xFFFF**. You are advised to customize the value as required. 54 55 56## What is the maximum length of a log record when HiLog Is used? Is it configurable? (API 9) 57 58The maximum length of a log record is 1,024 characters, and it is not changeable. 59 60 61## What is the purpose of using private in printing of formatted logs? (API 9) 62 63**Symptom** 64 65**private** is displayed in HiLog information when format parameters are of the %d or %s type in C++. 66 67**Solution** 68 69When format parameters such as **%d** and **%s** are directly used, the standard system uses **private** to replace the actual data for printing by default to prevent data leakage. To print the actual data, replace **%d** with **%{public}d** or replace **%s** with **%{public}s**. 70 71 72## What should I do if the hilog.debug log cannot be printed? (API 9) 73 74**Solution** 75 76Run **hdc std shell hilog -b D** to turn on the debugging switch. 77 78 79## Can I separate multiple strings by spaces in the tag parameter of the HiLog API? (API 9) 80 81Yes. 82 83 84## How does HiLog print the log information marked with the \{private\} tag? (API 9) 85 86**Solution** 87 88To print the log information marked with the \{private\} tag, run the command to disable the privacy mode: hdc shell hilog -p off 89 90 91## What are the cash log collection and performance troubleshooting functions provided by the HiLog system? (API 9) 92 93**Symptom** 94 95How do I use the cash log collection and performance troubleshooting functions provided by the HiLog system? 96 97**Solution** 98 99FaultLogger: collects crash logs. For details, see [FaultLogger](../reference/apis/js-apis-faultLogger.md). 100 101HiChecker: detects potential faults. For details, see [HiChecker](../reference/apis/js-apis-hichecker.md). 102 103hiTraceMeter: implements performance tracing. For details, see [hiTraceMeter](../reference/apis/js-apis-hitracemeter.md). 104 105 106## How do I control log output? (API 9) 107 108**Symptom** 109 110The output log varies according to environment requirements. 111 112**Solution** 113 114You can run the following command to adjust the log level to print the desired logs: 115 116hdc shell hilog -L <D/I/W/E/F> 117 118 119## Is there a limit on the tag length of HiLog? (API 9) 120 121The length of the entire tag is 32. 122 123 124## How do I view the appfreeze information in the logs? (API 9) 125 126Try the following procedure: 127 1281. Check the reason for the event. Fault location methods and examples are provided specifically to different reasons. 129 1302. Check the MSG information. 131 1323. Check the application stack information in OpenStacktraceCatcher as well as the HiLog information for the operation that leads to the event. 133 1344. Check the PeerBinderCatcher process to see if the current process is suspended by the peer binder. If there is a synchronous wait related to the current process, the corresponding PeerBinder Stacktrace information will be logged. It contains the stack information of the peer process that leads to suspension of the current process. 135 1365. Check the CPU usage of system processes and the memory usage of the current process. 137