1# HiLog<a name="EN-US_TOPIC_0000001115694144"></a> 2 3- [Introduction](#section11660541593) 4- [Directory Structure](#section161941989596) 5- [Constraints](#section119744591305) 6- [Usage](#section06487425716) 7 - [Available APIs](#section1551164914237) 8 - [Usage Guidelines](#section129654513264) 9 10- [Repositories Involved](#section177639411669) 11 12## Introduction<a name="section11660541593"></a> 13 14HiLog is the module of OpenHarmony that logs information such as user operations and system running status for the system framework, services, and applications. 15 16**Figure 1** Architecture of the HiLog module<a name="fig4460722185514"></a> 17 18 19 20 21User-space processes write logs to the ring buffer of hilogd through the log API. hilogd sends logs to the console for viewing or writes logs to the flash at the request of the hilog. 22 23The details are as follows: 24 25- **hilogd**: log service in the user space 26 271. hilogd is a resident service and is enabled by default when the system is started. 282. User-space processes call the log APIs to transfer the formatted log content to hilogd and store the content in its ring buffer. 29 30- **hilog**: command line tool for viewing logs 31 321. hilog reads the log content from the ring buffer of hilogd, filters the content if required, and then prints the content to the standard output. 33 34Supported functions: 35 36- Formatting of parameter privacy identifiers \(See the following example for details.\) 37- Flow control on excess log processes 38- Flow control on excess domains \(subsystems or modules\) involved in log printing 39- Log compression and flushing 40 41## Directory Structure<a name="section161941989596"></a> 42 43``` 44/base/hiviewdfx/hilog 45├── frameworks # Framework code 46│ └── native # HiLog Native implementation code 47├── interfaces # APIs 48│ └── native # External C/C++ APIs 49│ └── innerkits # Header files opened to internal subsystems 50│ └── kits # Header files opened to applications 51│ └── js # External js APIs 52├── services 53│ └── hilogd # HiLog resident service implementation 54│ └── hilogtool # HiLog tool implementation 55``` 56 57## Constraints<a name="section119744591305"></a> 58 59Clang 8.0.0 or later is required. 60 61## Usage<a name="section06487425716"></a> 62 63### Available APIs<a name="section1551164914237"></a> 64 65**Table 1** Major APIs of HiLog 66 67<a name="table5489165165714"></a> 68<table><thead align="left"><tr id="row12490195195718"><th class="cellrowborder" valign="top" width="14.09%" id="mcps1.2.4.1.1"><p id="p862411212488"><a name="p862411212488"></a><a name="p862411212488"></a><strong id="b68190161218"><a name="b68190161218"></a><a name="b68190161218"></a>Class</strong></p> 69</th> 70<th class="cellrowborder" valign="top" width="33.98%" id="mcps1.2.4.1.2"><p id="p10859172921116"><a name="p10859172921116"></a><a name="p10859172921116"></a>Method</p> 71</th> 72<th class="cellrowborder" valign="top" width="51.93%" id="mcps1.2.4.1.3"><p id="p104901150576"><a name="p104901150576"></a><a name="p104901150576"></a>Description</p> 73</th> 74</tr> 75</thead> 76<tbody><tr id="row34901758577"><td class="cellrowborder" valign="top" width="14.09%" headers="mcps1.2.4.1.1 "><p id="p16501115918497"><a name="p16501115918497"></a><a name="p16501115918497"></a>HiLogLabel</p> 77</td> 78<td class="cellrowborder" valign="top" width="33.98%" headers="mcps1.2.4.1.2 "><p id="p1550175974917"><a name="p1550175974917"></a><a name="p1550175974917"></a>HiLogLabel(int type, int domain, String tag)</p> 79</td> 80<td class="cellrowborder" valign="top" width="51.93%" headers="mcps1.2.4.1.3 "><p id="p135021859104915"><a name="p135021859104915"></a><a name="p135021859104915"></a>Constructs a log label, including the log type, domain, and tag.</p> 81</td> 82</tr> 83<tr id="row868117162916"><td class="cellrowborder" valign="top" width="14.09%" headers="mcps1.2.4.1.1 "><p id="p1215914385013"><a name="p1215914385013"></a><a name="p1215914385013"></a>HiLog</p> 84</td> 85<td class="cellrowborder" valign="top" width="33.98%" headers="mcps1.2.4.1.2 "><p id="p1415914345011"><a name="p1415914345011"></a><a name="p1415914345011"></a>Info(const HiLogLabel &label, const char *fmt, ...)</p> 86</td> 87<td class="cellrowborder" valign="top" width="51.93%" headers="mcps1.2.4.1.3 "><p id="p1274814305510"><a name="p1274814305510"></a><a name="p1274814305510"></a>Prints logs of the info level.</p> 88</td> 89</tr> 90</tbody> 91</table> 92 93### Usage Guidelines<a name="section129654513264"></a> 94 951. View logs. 96 97Run the **hilog | grep "MY\_TAG"** command in shell mode. 98 99``` 100Output in debug mode: 10101-26 11:01:06.870 1051 1051 W 00201/test: Failed to visit [https://gitee.com/openharmony](https://gitee.com/openharmony), reason:503. 102Output in release mode: 10301-26 11:01:06.870 1051 1051 W 00201/test: Failed to visit <private>, reason:503. 104``` 105 106## Repositories Involved<a name="section177639411669"></a> 107 108[DFX subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/dfx.md) 109 110[hiviewdfx\_hiview](https://gitee.com/openharmony/hiviewdfx_hiview/blob/master/README.md) 111 112**hiviewdfx\_hilog** 113 114[hiviewdfx\_hiappevent](https://gitee.com/openharmony/hiviewdfx_hiappevent/blob/master/README.md) 115 116[hiviewdfx\_hisysevent](https://gitee.com/openharmony/hiviewdfx_hisysevent/blob/master/README.md) 117 118[hiviewdfx\_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README.md) 119 120[hiviewdfx\_hilog\_lite](https://gitee.com/openharmony/hiviewdfx_hilog_lite/blob/master/README.md) 121 122[hiviewdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README.md) 123 124[hiviewdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README.md) 125 126