17405867cSopenharmony_ci# HiAppEvent<a name="EN-US_TOPIC_0000001162014029"></a> 27405867cSopenharmony_ci 37405867cSopenharmony_ci- [Introduction](#section11660541593) 47405867cSopenharmony_ci- [Directory Structure](#section161941989596) 57405867cSopenharmony_ci- [Compilation and Building](#section137768191623) 67405867cSopenharmony_ci- [Usage](#section1312121216216) 77405867cSopenharmony_ci - [Available APIs](#section1551164914237) 87405867cSopenharmony_ci - [How to Use](#section129654513264) 97405867cSopenharmony_ci 107405867cSopenharmony_ci- [Repositories Involved](#section1371113476307) 117405867cSopenharmony_ci 127405867cSopenharmony_ci## Introduction<a name="section11660541593"></a> 137405867cSopenharmony_ci 147405867cSopenharmony_ciHiAppEvent is an OpenHarmony module that provides the event logging function for applications to log the fault, statistical, security, and user behavior events reported during running. Based on event information, you will be able to analyze the running status of applications. 157405867cSopenharmony_ci 167405867cSopenharmony_ci<strong>Figure 1</strong> HiAppEvent architecture<a name="fig32154874419"></a> 177405867cSopenharmony_ci 187405867cSopenharmony_ci 197405867cSopenharmony_ci## Directory Structure<a name="section161941989596"></a> 207405867cSopenharmony_ci 217405867cSopenharmony_ci``` 227405867cSopenharmony_ci/base/hiviewdfx/hiappevent # HiAppEvent source code 237405867cSopenharmony_ci├── frameworks # Framework code 247405867cSopenharmony_ci│ └── native # Native implementation code of logging APIs 257405867cSopenharmony_ci├── interfaces # External APIs 267405867cSopenharmony_ci│ └── js # JS APIs 277405867cSopenharmony_ci│ └── innerkits # JS API implementation code 287405867cSopenharmony_ci│ └── napi # JS APIs implemented based on NAPI 297405867cSopenharmony_ci├── test # Test cases 307405867cSopenharmony_ci``` 317405867cSopenharmony_ci 327405867cSopenharmony_ci## Compilation and Building<a name="section137768191623"></a> 337405867cSopenharmony_ci 347405867cSopenharmony_ciUse Clang 8.0.0 and C++11 or higher. 357405867cSopenharmony_ci 367405867cSopenharmony_ci## Usage<a name="section1312121216216"></a> 377405867cSopenharmony_ci 387405867cSopenharmony_ci### Available APIs<a name="section1551164914237"></a> 397405867cSopenharmony_ci 407405867cSopenharmony_ci#### JS APIs 417405867cSopenharmony_ci 427405867cSopenharmony_ci<strong>Table 1</strong> JS APIs for event logging 437405867cSopenharmony_ci 447405867cSopenharmony_ci<a name="table107919166559"></a> 457405867cSopenharmony_ci<table><thead align="left"><tr id="row1880201655520"><th class="cellrowborder" valign="top" width="15.981598159815983%" id="mcps1.2.4.1.1"><p id="p5801164558"><a name="p5801164558"></a><a name="p5801164558"></a>Module</p> 467405867cSopenharmony_ci</th> 477405867cSopenharmony_ci<th class="cellrowborder" valign="top" width="50.68506850685068%" id="mcps1.2.4.1.2"><p id="p168019163559"><a name="p168019163559"></a><a name="p168019163559"></a>API</p> 487405867cSopenharmony_ci</th> 497405867cSopenharmony_ci<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p780101685516"><a name="p780101685516"></a><a name="p780101685516"></a>Description</p> 507405867cSopenharmony_ci</th> 517405867cSopenharmony_ci</tr> 527405867cSopenharmony_ci</thead> 537405867cSopenharmony_ci<tbody><tr id="row148011162552"><td class="cellrowborder" valign="top" width="15.981598159815983%" headers="mcps1.2.4.1.1 "><p id="p188061611553"><a name="p188061611553"></a><a name="p188061611553"></a>hiAppEvent</p> 547405867cSopenharmony_ci</td> 557405867cSopenharmony_ci<td class="cellrowborder" valign="top" width="50.68506850685068%" headers="mcps1.2.4.1.2 "><p id="p1880171695519"><a name="p1880171695519"></a><a name="p1880171695519"></a>write(string eventName, EventType type, object keyValues, AsyncCallback<void> callback): void</p> 567405867cSopenharmony_ci</td> 577405867cSopenharmony_ci<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p983410810310"><a name="p983410810310"></a><a name="p983410810310"></a>Logs application events in asynchronous mode. This function uses an asynchronous callback to return the result.</p> 587405867cSopenharmony_ci<p id="p683519817319"><a name="p683519817319"></a><a name="p683519817319"></a>Input arguments:</p> 597405867cSopenharmony_ci<a name="ul108351681336"></a><a name="ul108351681336"></a><ul id="ul108351681336"><li><strong>eventName</strong>: indicates the event name. </li><li><strong>type</strong>: indicates the event type. </li><li><strong>keyValues</strong>: indicates the key-value pairs of event parameters. The value is in the JSON format. </li><li><strong>callback</strong>: indicates the callback used to process the received return value. The value <strong>0</strong> indicates that the event parameter verification is successful, and the event will be written to the event file asynchronously. A value greater than <strong>0</strong> indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored. A value smaller than <strong>0</strong> indicates that the event parameter verification fails, and the event will not be written to the event file asynchronously.</li></ul> 607405867cSopenharmony_ci</td> 617405867cSopenharmony_ci</tr> 627405867cSopenharmony_ci<tr id="row78021665512"><td class="cellrowborder" valign="top" width="15.981598159815983%" headers="mcps1.2.4.1.1 "><p id="p1380916165510"><a name="p1380916165510"></a><a name="p1380916165510"></a>hiAppEvent</p> 637405867cSopenharmony_ci</td> 647405867cSopenharmony_ci<td class="cellrowborder" valign="top" width="50.68506850685068%" headers="mcps1.2.4.1.2 "><p id="p1380161665518"><a name="p1380161665518"></a><a name="p1380161665518"></a>write(string eventName, EventType type, object keyValues): Promise<void></p> 657405867cSopenharmony_ci</td> 667405867cSopenharmony_ci<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p12532811415"><a name="p12532811415"></a><a name="p12532811415"></a>Logs application events in asynchronous mode. This function uses a promise to return the result.</p> 677405867cSopenharmony_ci<p id="p75313814417"><a name="p75313814417"></a><a name="p75313814417"></a>Input arguments: same as those in the preceding function</p> 687405867cSopenharmony_ci</td> 697405867cSopenharmony_ci</tr> 707405867cSopenharmony_ci</tbody> 717405867cSopenharmony_ci</table> 727405867cSopenharmony_ci 737405867cSopenharmony_ci<strong>Table 2</strong> JS event types (EventType) 747405867cSopenharmony_ci 757405867cSopenharmony_ci| Type| Description| 767405867cSopenharmony_ci| --------- | -------------- | 777405867cSopenharmony_ci| FAULT | Fault event| 787405867cSopenharmony_ci| STATISTIC | Statistical event| 797405867cSopenharmony_ci| SECURITY | Security event| 807405867cSopenharmony_ci| BEHAVIOR | Behavior event| 817405867cSopenharmony_ci 827405867cSopenharmony_ci<strong>Table 3</strong> JS APIs for event logging configuration 837405867cSopenharmony_ci 847405867cSopenharmony_ci<table> 857405867cSopenharmony_ci <tr> 867405867cSopenharmony_ci <td><strong>Module</strong></td> 877405867cSopenharmony_ci <td><strong>API</strong></td> 887405867cSopenharmony_ci <td><strong>Description</strong></td> 897405867cSopenharmony_ci </tr> 907405867cSopenharmony_ci <tr> 917405867cSopenharmony_ci <td>hiAppEvent</td> 927405867cSopenharmony_ci <td>configure(config: ConfigOption): boolean</td> 937405867cSopenharmony_ci <td>Sets the configuration options for application event logging. <br/>Input arguments:<ul><li><strong>config</strong>: indicates configuration options for application event logging. </li></ul>Return value: The value <strong>true</strong> indicates the operation is successful, and the value <strong>false</strong> indicates the opposite.</td> 947405867cSopenharmony_ci </tr> 957405867cSopenharmony_ci</table> 967405867cSopenharmony_ci 977405867cSopenharmony_ci<strong>Table 4</strong> JS logging configuration options (ConfigOption) 987405867cSopenharmony_ci 997405867cSopenharmony_ci| Name| Type| Mandatory| Description| 1007405867cSopenharmony_ci| ---------- | ------- | ---- | ------------------------------------------------------------ | 1017405867cSopenharmony_ci| disable | boolean | No| Application event logging switch. The value <strong>true</strong> means to disable the application event logging function, and the value <strong>false</strong> means the opposite.| 1027405867cSopenharmony_ci| maxStorage | string | No| Maximum size of the event file storage directory. The default value is <strong>10M</strong>. If the specified size is exceeded, the oldest event logging files in the directory will be deleted to free up space.| 1037405867cSopenharmony_ci 1047405867cSopenharmony_ci<strong>Table 5</strong> JS predefined event name constants (Event) 1057405867cSopenharmony_ci 1067405867cSopenharmony_ci| Constant| Type| Description| 1077405867cSopenharmony_ci| ------------------------- | ------ | -------------------- | 1087405867cSopenharmony_ci| USER_LOGIN | string | User login event.| 1097405867cSopenharmony_ci| USER_LOGOUT | string | User logout event.| 1107405867cSopenharmony_ci| DISTRIBUTED\_SERVICE\_START| string | Distributed service startup event.| 1117405867cSopenharmony_ci 1127405867cSopenharmony_ci<strong>Table 6</strong> JS predefined parameter name constants (Param) 1137405867cSopenharmony_ci 1147405867cSopenharmony_ci| Constant| Type| Description| 1157405867cSopenharmony_ci| ------------------------------- | ------ | ------------------ | 1167405867cSopenharmony_ci| USER_ID | string | Custom user ID.| 1177405867cSopenharmony_ci| DISTRIBUTED\_SERVICE\_NAME| string | Distributed service name.| 1187405867cSopenharmony_ci| DISTRIBUTED\_SERVICE\_INSTANCE\_ID| string | Distributed service instance ID.| 1197405867cSopenharmony_ci 1207405867cSopenharmony_ci#### Native APIs 1217405867cSopenharmony_ci 1227405867cSopenharmony_ci<strong>Table 1</strong> Native APIs for event logging 1237405867cSopenharmony_ci 1247405867cSopenharmony_ci<table> 1257405867cSopenharmony_ci <tr> 1267405867cSopenharmony_ci <td><strong>API</strong></td> 1277405867cSopenharmony_ci <td><strong>Return Value</strong></td> 1287405867cSopenharmony_ci <td><strong>Description</strong></td> 1297405867cSopenharmony_ci </tr> 1307405867cSopenharmony_ci <tr> 1317405867cSopenharmony_ci <td>OH_HiAppEvent_Write(const char* domain, const char* name, enum EventType type, const ParamList list)</td> 1327405867cSopenharmony_ci <td>int</td> 1337405867cSopenharmony_ci <td>Implements logging of application events. <br/>Input arguments: 1347405867cSopenharmony_ci <ul> 1357405867cSopenharmony_ci <li><strong>domain</strong>: indicates the event domain.</li> 1367405867cSopenharmony_ci <li><strong>name</strong>: indicates the event name.</li> 1377405867cSopenharmony_ci <li><strong>type</strong>: indicates the event type.</li> 1387405867cSopenharmony_ci <li><strong>list</strong>: indicates the event parameter list. It is actually a pointer to the the linked list head node — <strong>ParamListNode*</strong>. Each parameter in the list consists of a parameter name and a parameter value.</li> 1397405867cSopenharmony_ci </ul>Return value: error code in the int format. 1407405867cSopenharmony_ci </td> 1417405867cSopenharmony_ci </tr> 1427405867cSopenharmony_ci</table> 1437405867cSopenharmony_ci 1447405867cSopenharmony_ci<strong>Table 2</strong> Native APIs for constructing ParamList 1457405867cSopenharmony_ci 1467405867cSopenharmony_ci| API| Return Value| Description| 1477405867cSopenharmony_ci| ------------------------------------------------------------ | --------- | ------------------------------------------------------------ | 1487405867cSopenharmony_ci| OH\_HiAppEvent\_CreateParamList()| ParamList | Creates a <strong>ParamList</strong> node. A pointer to the created node is returned.| 1497405867cSopenharmony_ci| OH_HiAppEvent_DestroyParamList(ParamList list) | void | Deletes <strong>ParamList</strong> nodes one by one from the head node and releases the memory.| 1507405867cSopenharmony_ci| OH_HiAppEvent_AddBoolParam(ParamList list, const char* name, bool boolean) | ParamList | Creates a parameter node of the <strong>bool</strong> type and adds it to <strong>ParamList</strong>.| 1517405867cSopenharmony_ci| OH_HiAppEvent_AddBoolArrayParam(ParamList list, const char* name, const bool* booleans, int arrSize) | ParamList | Creates a parameter node of the <strong>bool</strong> array type and adds it to <strong>ParamList</strong>.| 1527405867cSopenharmony_ci| OH_HiAppEvent_AddInt8Param(ParamList list, const char* name, int8_t num) | ParamList | Creates a parameter node of the <strong>int8_t</strong> type and adds it to <strong>ParamList</strong>.| 1537405867cSopenharmony_ci| OH_HiAppEvent_AddInt8ArrayParam(ParamList list, const char* name, const int8_t* nums, int arrSize) | ParamList | Creates a parameter node of the <strong>int8_t</strong> array type and adds it to <strong>ParamList</strong>.| 1547405867cSopenharmony_ci| OH_HiAppEvent_AddInt16Param(ParamList list, const char* name, int16_t num) | ParamList | Creates a parameter node of the <strong>int16_t</strong> type and adds it to <strong>ParamList</strong>.| 1557405867cSopenharmony_ci| OH_HiAppEvent_AddInt16ArrayParam(ParamList list, const char* name, const int16_t* nums, int arrSize) | ParamList | Creates a parameter node of the <strong>int16_t</strong> array type and adds it to <strong>ParamList</strong>.| 1567405867cSopenharmony_ci| OH_HiAppEvent_AddInt32Param(ParamList list, const char* name, int32_t num) | ParamList | Creates a parameter node of the <strong>int32_t</strong> type and adds it to <strong>ParamList</strong>.| 1577405867cSopenharmony_ci| OH_HiAppEvent_AddInt32ArrayParam(ParamList list, const char* name, const int32_t* nums, int arrSize) | ParamList | Creates a parameter node of the <strong>int32_t</strong> array type and adds it to <strong>ParamList</strong>.| 1587405867cSopenharmony_ci| OH_HiAppEvent_AddInt64Param(ParamList list, const char* name, int64_t num) | ParamList | Creates a parameter node of the <strong>int64_t</strong> type and adds it to <strong>ParamList</strong>.| 1597405867cSopenharmony_ci| OH_HiAppEvent_AddInt64ArrayParam(ParamList list, const char* name, const int64_t* nums, int arrSize) | ParamList | Creates a parameter node of the <strong>int64_t</strong> array type and adds the node to <strong>ParamList</strong>.| 1607405867cSopenharmony_ci| OH_HiAppEvent_AddFloatParam(ParamList list, const char* name, float num) | ParamList | Creates a parameter node of the <strong>float</strong> type and adds it to <strong>ParamList</strong>.| 1617405867cSopenharmony_ci| OH_HiAppEvent_AddFloatArrayParam(ParamList list, const char* name, const float* nums, int arrSize) | ParamList | Creates a parameter node of the <strong>float</strong> array type and adds it to <strong>ParamList</strong>.| 1627405867cSopenharmony_ci| OH_HiAppEvent_AddDoubleParam(ParamList list, const char* name, double num) | ParamList | Creates a parameter node of the <strong>double</strong> type and adds it to <strong>ParamList</strong>.| 1637405867cSopenharmony_ci| OH_HiAppEvent_AddDoubleArrayParam(ParamList list, const char* name, const double* nums, int arrSize) | ParamList | Creates a parameter node of the <strong>double</strong> array type and adds it to <strong>ParamList</strong>.| 1647405867cSopenharmony_ci| OH_HiAppEvent_AddStringParam(ParamList list, const char* name, const char* str) | ParamList | Creates a parameter node of the <strong>char*</strong> type and adds it to <strong>ParamList</strong>.| 1657405867cSopenharmony_ci| OH_HiAppEvent_AddStringArrayParam(ParamList list, const char* name, const char * const *strs, int arrSize) | ParamList | Creates a parameter node of the <strong>char*</strong> array type and adds it to <strong>ParamList</strong>.| 1667405867cSopenharmony_ci 1677405867cSopenharmony_ci<strong>Table 3</strong> Native APIs for event logging configuration 1687405867cSopenharmony_ci 1697405867cSopenharmony_ci<table> 1707405867cSopenharmony_ci <tr> 1717405867cSopenharmony_ci <td><strong>API</strong></td> 1727405867cSopenharmony_ci <td><strong>Return Value</strong></td> 1737405867cSopenharmony_ci <td><strong>Description</strong></td> 1747405867cSopenharmony_ci </tr> 1757405867cSopenharmony_ci <tr> 1767405867cSopenharmony_ci <td>OH_HiAppEvent_Configure(const char* name, const char* value)</td> 1777405867cSopenharmony_ci <td>bool</td> 1787405867cSopenharmony_ci <td>Sets the configuration options for application event logging. <br/>Input arguments: 1797405867cSopenharmony_ci <ul> 1807405867cSopenharmony_ci <li><strong>name</strong>: indicates the name of a configuration item. You can pass a predefined configuration item constant.</li> 1817405867cSopenharmony_ci <li><strong>value</strong>: indicates the value of the configuration item.</li> 1827405867cSopenharmony_ci </ul>Return value: The value <strong>true</strong> indicates the operation is successful, and the value <strong>false</strong> indicates the opposite. 1837405867cSopenharmony_ci </td> 1847405867cSopenharmony_ci </tr> 1857405867cSopenharmony_ci</table> 1867405867cSopenharmony_ci 1877405867cSopenharmony_ci<strong>Table 4</strong> Predefined configuration item constants 1887405867cSopenharmony_ci 1897405867cSopenharmony_ci| Constant| Type| Description| 1907405867cSopenharmony_ci| ----------- | ------------ | ------------------------------------------------------------ | 1917405867cSopenharmony_ci| DISABLE | const char[] | Sets the application event logging switch. The value <strong>true</strong> means to disable the application event logging function, and the value <strong>false</strong> means the opposite.| 1927405867cSopenharmony_ci| MAX_STORAGE | const char[] | Specifies the maximum size of the event file storage directory. The default value is <strong>10M</strong>.| 1937405867cSopenharmony_ci 1947405867cSopenharmony_ci<strong>Table 5</strong> Predefined event name constants 1957405867cSopenharmony_ci 1967405867cSopenharmony_ci| Constant| Type| Description| 1977405867cSopenharmony_ci| ------------------------------- | ------------ | ------------------------ | 1987405867cSopenharmony_ci| EVENT_USER_LOGIN | const char[] | Name of the user login event.| 1997405867cSopenharmony_ci| EVENT_USER_LOGOUT | const char[] | Name of the user logout event.| 2007405867cSopenharmony_ci| EVENT_DISTRIBUTED_SERVICE_START | const char[] | Name of the distributed service startup event.| 2017405867cSopenharmony_ci 2027405867cSopenharmony_ci<strong>Table 6</strong> Predefined parameter name constants 2037405867cSopenharmony_ci 2047405867cSopenharmony_ci| Constant| Type| Description| 2057405867cSopenharmony_ci| ------------------------------------- | ------------ | ------------------ | 2067405867cSopenharmony_ci| PARAM_USER_ID | const char[] | Custom user ID.| 2077405867cSopenharmony_ci| PARAM_DISTRIBUTED_SERVICE_NAME | const char[] | Distributed service name.| 2087405867cSopenharmony_ci| PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID | const char[] | Distributed service instance ID.| 2097405867cSopenharmony_ci 2107405867cSopenharmony_ci### How to Use<a name="section129654513264"></a> 2117405867cSopenharmony_ci 2127405867cSopenharmony_ci#### JS 2137405867cSopenharmony_ci 2147405867cSopenharmony_ci1. Develop the source code. 2157405867cSopenharmony_ci 2167405867cSopenharmony_ci Import the HiAppEvent module. 2177405867cSopenharmony_ci 2187405867cSopenharmony_ci ```js 2197405867cSopenharmony_ci import hiAppEvent from '@ohos.hiAppEvent' 2207405867cSopenharmony_ci ``` 2217405867cSopenharmony_ci 2227405867cSopenharmony_ci2. Log application events. 2237405867cSopenharmony_ci 2247405867cSopenharmony_ci ```js 2257405867cSopenharmony_ci // Callback mode 2267405867cSopenharmony_ci hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"}, (err, value) => { 2277405867cSopenharmony_ci if (err) { 2287405867cSopenharmony_ci // Event writing failed: The event contains invalid parameters or the event parameter verification fails. 2297405867cSopenharmony_ci console.error(`failed to write event because ${err.code}`); 2307405867cSopenharmony_ci return; 2317405867cSopenharmony_ci } 2327405867cSopenharmony_ci 2337405867cSopenharmony_ci // Event writing succeeded. 2347405867cSopenharmony_ci console.log(`success to write event: ${value}`); 2357405867cSopenharmony_ci }); 2367405867cSopenharmony_ci 2377405867cSopenharmony_ci // Promise mode 2387405867cSopenharmony_ci hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"}) 2397405867cSopenharmony_ci .then((value) => { 2407405867cSopenharmony_ci // Event writing succeeded. 2417405867cSopenharmony_ci console.log(`success to write event: ${value}`); 2427405867cSopenharmony_ci }).catch((err) => { 2437405867cSopenharmony_ci // Event writing failed: The event contains invalid parameters or the event parameter verification fails. 2447405867cSopenharmony_ci console.error(`failed to write event because ${err.code}`); 2457405867cSopenharmony_ci }); 2467405867cSopenharmony_ci ``` 2477405867cSopenharmony_ci 2487405867cSopenharmony_ci3. Customize the application event logging function. 2497405867cSopenharmony_ci 2507405867cSopenharmony_ci ```js 2517405867cSopenharmony_ci // Set the application event logging switch. 2527405867cSopenharmony_ci hiAppEvent.configure({ 2537405867cSopenharmony_ci disable: true 2547405867cSopenharmony_ci }) 2557405867cSopenharmony_ci 2567405867cSopenharmony_ci // Set the maximum size of the directory that stores the event logging files. 2577405867cSopenharmony_ci hiAppEvent.configure({ 2587405867cSopenharmony_ci maxStorage: '100M' 2597405867cSopenharmony_ci }) 2607405867cSopenharmony_ci ``` 2617405867cSopenharmony_ci 2627405867cSopenharmony_ci#### Native 2637405867cSopenharmony_ci 2647405867cSopenharmony_ci1. Develop the source code. 2657405867cSopenharmony_ci 2667405867cSopenharmony_ci Import the HiAppEvent module. 2677405867cSopenharmony_ci 2687405867cSopenharmony_ci ```c++ 2697405867cSopenharmony_ci #include "hiappevent/hiappevent.h" 2707405867cSopenharmony_ci ``` 2717405867cSopenharmony_ci 2727405867cSopenharmony_ci2. Log application events. 2737405867cSopenharmony_ci 2747405867cSopenharmony_ci ```c++ 2757405867cSopenharmony_ci // 1. Create an empty <strong>ParamList</strong> object. 2767405867cSopenharmony_ci ParamList list = OH_HiAppEvent_CreateParamList(); 2777405867cSopenharmony_ci 2787405867cSopenharmony_ci // 2. Adds key-value pair parameters to the <strong>ParamList</strong> object. 2797405867cSopenharmony_ci // 2.1 Pass a value in the int32_t format. 2807405867cSopenharmony_ci int32_t num = 1; 2817405867cSopenharmony_ci OH_HiAppEvent_AddInt32Param(list, "int32_key", num); 2827405867cSopenharmony_ci // 2.2 Pass a value in the int32_t array format. 2837405867cSopenharmony_ci int32_t nums3[] = {1, INT32_MAX, INT32_MIN}; 2847405867cSopenharmony_ci OH_HiAppEvent_AddInt32ArrayParam(list, "int32_arr_key", nums3, sizeof(nums3) / sizeof(nums3[0])); 2857405867cSopenharmony_ci // 2.3 Pass a parameter value in the string array format. 2867405867cSopenharmony_ci char str1[] = "hello"; 2877405867cSopenharmony_ci char str2[] = "world"; 2887405867cSopenharmony_ci char* strs[] = {str1, str2}; 2897405867cSopenharmony_ci OH_HiAppEvent_AddStringArrayParam(list, "string_arr_key", strs, sizeof(strs) / sizeof(strs[0])); 2907405867cSopenharmony_ci 2917405867cSopenharmony_ci // 3. Log application events. 2927405867cSopenharmony_ci int result = OH_HiAppEvent_Write("domain", "name", BEHAVIOR, list); 2937405867cSopenharmony_ci printf("HiAppEvent logging test, res=%d\n", result); 2947405867cSopenharmony_ci 2957405867cSopenharmony_ci // 4. Destroy the <strong>ParamLIst</strong> object to release the memory. 2967405867cSopenharmony_ci OH_HiAppEvent_DestroyParamList(list); 2977405867cSopenharmony_ci ``` 2987405867cSopenharmony_ci 2997405867cSopenharmony_ci3. Customize the application event logging function. 3007405867cSopenharmony_ci 3017405867cSopenharmony_ci ```c++ 3027405867cSopenharmony_ci // Disable the application event logging function. 3037405867cSopenharmony_ci OH_HiAppEvent_Configure(DISABLE, "true"); 3047405867cSopenharmony_ci 3057405867cSopenharmony_ci // Set the maximum size of the directory that stores the event logging files to 100M. 3067405867cSopenharmony_ci OH_HiAppEvent_Configure(MAX_STORAGE, "100M"); 3077405867cSopenharmony_ci ``` 3087405867cSopenharmony_ci 3097405867cSopenharmony_ci## Repositories Involved<a name="section1371113476307"></a> 3107405867cSopenharmony_ci 3117405867cSopenharmony_ci[DFX Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/dfx.md) 3127405867cSopenharmony_ci 3137405867cSopenharmony_ci[hiviewdfx\_hiview](https://gitee.com/openharmony/hiviewdfx_hiview/blob/master/README.md) 3147405867cSopenharmony_ci 3157405867cSopenharmony_ci[hiviewdfx\_hilog](https://gitee.com/openharmony/hiviewdfx_hilog/blob/master/README.md) 3167405867cSopenharmony_ci 3177405867cSopenharmony_ci<strong>hiviewdfx\_hiappevent</strong> 3187405867cSopenharmony_ci 3197405867cSopenharmony_ci[hiviewdfx\_hisysevent](https://gitee.com/openharmony/hiviewdfx_hisysevent/blob/master/README.md) 3207405867cSopenharmony_ci 3217405867cSopenharmony_ci[hiviewdfx\_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README.md) 3227405867cSopenharmony_ci 3237405867cSopenharmony_ci[hiviewdfx\_hilog\_lite](https://gitee.com/openharmony/hiviewdfx_hilog_lite/blob/master/README.md) 3247405867cSopenharmony_ci 3257405867cSopenharmony_ci[hiviewdfx\_hievent\_lite](https://gitee.com/openharmony/hiviewdfx_hievent_lite/blob/master/README.md) 3267405867cSopenharmony_ci 3277405867cSopenharmony_ci[hiviewdfx\_hiview\_lite](https://gitee.com/openharmony/hiviewdfx_hiview_lite/blob/master/README.md) 328