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