12498b56bSopenharmony_ci# HiLog<a name="EN-US_TOPIC_0000001115694144"></a> 22498b56bSopenharmony_ci 32498b56bSopenharmony_ci- [Introduction](#section11660541593) 42498b56bSopenharmony_ci- [Directory Structure](#section161941989596) 52498b56bSopenharmony_ci- [Constraints](#section119744591305) 62498b56bSopenharmony_ci- [Usage](#section06487425716) 72498b56bSopenharmony_ci - [Available APIs](#section1551164914237) 82498b56bSopenharmony_ci - [Usage Guidelines](#section129654513264) 92498b56bSopenharmony_ci 102498b56bSopenharmony_ci- [Repositories Involved](#section177639411669) 112498b56bSopenharmony_ci 122498b56bSopenharmony_ci## Introduction<a name="section11660541593"></a> 132498b56bSopenharmony_ci 142498b56bSopenharmony_ciHiLog is the module of OpenHarmony that logs information such as user operations and system running status for the system framework, services, and applications. 152498b56bSopenharmony_ci 162498b56bSopenharmony_ci**Figure 1** Architecture of the HiLog module<a name="fig4460722185514"></a> 172498b56bSopenharmony_ci 182498b56bSopenharmony_ci 192498b56bSopenharmony_ci 202498b56bSopenharmony_ci 212498b56bSopenharmony_ciUser-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. 222498b56bSopenharmony_ci 232498b56bSopenharmony_ciThe details are as follows: 242498b56bSopenharmony_ci 252498b56bSopenharmony_ci- **hilogd**: log service in the user space 262498b56bSopenharmony_ci 272498b56bSopenharmony_ci1. hilogd is a resident service and is enabled by default when the system is started. 282498b56bSopenharmony_ci2. User-space processes call the log APIs to transfer the formatted log content to hilogd and store the content in its ring buffer. 292498b56bSopenharmony_ci 302498b56bSopenharmony_ci- **hilog**: command line tool for viewing logs 312498b56bSopenharmony_ci 322498b56bSopenharmony_ci1. 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. 332498b56bSopenharmony_ci 342498b56bSopenharmony_ciSupported functions: 352498b56bSopenharmony_ci 362498b56bSopenharmony_ci- Formatting of parameter privacy identifiers \(See the following example for details.\) 372498b56bSopenharmony_ci- Flow control on excess log processes 382498b56bSopenharmony_ci- Flow control on excess domains \(subsystems or modules\) involved in log printing 392498b56bSopenharmony_ci- Log compression and flushing 402498b56bSopenharmony_ci 412498b56bSopenharmony_ci## Directory Structure<a name="section161941989596"></a> 422498b56bSopenharmony_ci 432498b56bSopenharmony_ci``` 442498b56bSopenharmony_ci/base/hiviewdfx/hilog 452498b56bSopenharmony_ci├── frameworks # Framework code 462498b56bSopenharmony_ci│ └── native # HiLog Native implementation code 472498b56bSopenharmony_ci├── interfaces # APIs 482498b56bSopenharmony_ci│ └── native # External C/C++ APIs 492498b56bSopenharmony_ci│ └── innerkits # Header files opened to internal subsystems 502498b56bSopenharmony_ci│ └── kits # Header files opened to applications 512498b56bSopenharmony_ci│ └── js # External js APIs 522498b56bSopenharmony_ci├── services 532498b56bSopenharmony_ci│ └── hilogd # HiLog resident service implementation 542498b56bSopenharmony_ci│ └── hilogtool # HiLog tool implementation 552498b56bSopenharmony_ci``` 562498b56bSopenharmony_ci 572498b56bSopenharmony_ci## Constraints<a name="section119744591305"></a> 582498b56bSopenharmony_ci 592498b56bSopenharmony_ciClang 8.0.0 or later is required. 602498b56bSopenharmony_ci 612498b56bSopenharmony_ci## Usage<a name="section06487425716"></a> 622498b56bSopenharmony_ci 632498b56bSopenharmony_ci### Available APIs<a name="section1551164914237"></a> 642498b56bSopenharmony_ci 652498b56bSopenharmony_ci**Table 1** Major APIs of HiLog 662498b56bSopenharmony_ci 672498b56bSopenharmony_ci<a name="table5489165165714"></a> 682498b56bSopenharmony_ci<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> 692498b56bSopenharmony_ci</th> 702498b56bSopenharmony_ci<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> 712498b56bSopenharmony_ci</th> 722498b56bSopenharmony_ci<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> 732498b56bSopenharmony_ci</th> 742498b56bSopenharmony_ci</tr> 752498b56bSopenharmony_ci</thead> 762498b56bSopenharmony_ci<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> 772498b56bSopenharmony_ci</td> 782498b56bSopenharmony_ci<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> 792498b56bSopenharmony_ci</td> 802498b56bSopenharmony_ci<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> 812498b56bSopenharmony_ci</td> 822498b56bSopenharmony_ci</tr> 832498b56bSopenharmony_ci<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> 842498b56bSopenharmony_ci</td> 852498b56bSopenharmony_ci<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> 862498b56bSopenharmony_ci</td> 872498b56bSopenharmony_ci<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> 882498b56bSopenharmony_ci</td> 892498b56bSopenharmony_ci</tr> 902498b56bSopenharmony_ci</tbody> 912498b56bSopenharmony_ci</table> 922498b56bSopenharmony_ci 932498b56bSopenharmony_ci### Usage Guidelines<a name="section129654513264"></a> 942498b56bSopenharmony_ci 952498b56bSopenharmony_ci1. View logs. 962498b56bSopenharmony_ci 972498b56bSopenharmony_ciRun the **hilog | grep "MY\_TAG"** command in shell mode. 982498b56bSopenharmony_ci 992498b56bSopenharmony_ci``` 1002498b56bSopenharmony_ciOutput in debug mode: 1012498b56bSopenharmony_ci01-26 11:01:06.870 1051 1051 W 00201/test: Failed to visit [https://gitee.com/openharmony](https://gitee.com/openharmony), reason:503. 1022498b56bSopenharmony_ciOutput in release mode: 1032498b56bSopenharmony_ci01-26 11:01:06.870 1051 1051 W 00201/test: Failed to visit <private>, reason:503. 1042498b56bSopenharmony_ci``` 1052498b56bSopenharmony_ci 1062498b56bSopenharmony_ci## Repositories Involved<a name="section177639411669"></a> 1072498b56bSopenharmony_ci 1082498b56bSopenharmony_ci[DFX subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/dfx.md) 1092498b56bSopenharmony_ci 1102498b56bSopenharmony_ci[hiviewdfx\_hiview](https://gitee.com/openharmony/hiviewdfx_hiview/blob/master/README.md) 1112498b56bSopenharmony_ci 1122498b56bSopenharmony_ci**hiviewdfx\_hilog** 1132498b56bSopenharmony_ci 1142498b56bSopenharmony_ci[hiviewdfx\_hiappevent](https://gitee.com/openharmony/hiviewdfx_hiappevent/blob/master/README.md) 1152498b56bSopenharmony_ci 1162498b56bSopenharmony_ci[hiviewdfx\_hisysevent](https://gitee.com/openharmony/hiviewdfx_hisysevent/blob/master/README.md) 1172498b56bSopenharmony_ci 1182498b56bSopenharmony_ci[hiviewdfx\_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README.md) 1192498b56bSopenharmony_ci 1202498b56bSopenharmony_ci[hiviewdfx\_hilog\_lite](https://gitee.com/openharmony/hiviewdfx_hilog_lite/blob/master/README.md) 1212498b56bSopenharmony_ci 1222498b56bSopenharmony_ci[hiviewdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README.md) 1232498b56bSopenharmony_ci 1242498b56bSopenharmony_ci[hiviewdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README.md) 1252498b56bSopenharmony_ci 126