# HiSysEvent Logging ## Overview ### Introduction HiSysEvent provides event logging APIs for OpenHarmony to record important information of key processes during system running, helping you locate faults. In addition, you can upload the log data to the cloud for big data analytics. ### Constraints Before logging system events, you need to configure HiSysEvent logging. For details, see [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md). ## Development Guidelines ### Available APIs The following table lists the C++ APIs provided by the HiSysEvent class. For details about the HiSysEvent class, see the API reference. **Table 1** C++ APIs provided by HiSysEvent | API| Description| | -------- | --------- | | template<typename... Types> static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues) | Logs system events.

Input arguments: Return value: | **Table 2** Description of HiSysEvent::Domain APIs | API| Description| | -------- | --------- | | static const std::string AAFWK | Atomic ability subsystem| | static const std::string APPEXECFWK | User program framework subsystem| | static const std::string ACCOUNT | Account subsystem| | static const std::string ACE | JS application framework| | static const std::string AI | AI subsystem| | static const std::string BARRIER_FREE | Accessibility subsystem| | static const std::string BIOMETRICS | Biometric recognition subsystem| | static const std::string CCRUNTIME |C/C++ operating environment subsystem| | static const std::string COMMUNICATION | Public communication subsystem| | static const std::string DEVELOPTOOLS | Development toolchain subsystem| | static const std::string DISTRIBUTED_DATAMGR | Distributed data management subsystem| | static const std::string DISTRIBUTED_SCHEDULE | Distributed Scheduler subsystem| | static const std::string GLOBAL | Globalization subsystem| | static const std::string GRAPHIC | Graphics subsystem| | static const std::string HIVIEWDFX | DFX subsystem| | static const std::string IAWARE | Scheduling and resource management subsystem| | static const std::string INTELLI_ACCESSORIES | Smart accessory subsystem| | static const std::string INTELLI_TV | Smart TV subsystem| | static const std::string IVI_HARDWARE | IVI-dedicated hardware subsystem| | static const std::string LOCATION | LBS subsystem| | static const std::string MSDP | MSDP subsystem| | static const std::string MULTI_MEDIA | Media subsystem| | static const std::string MULTI_MODAL_INPUT | Multimode input subsystem| | static const std::string NOTIFICATION | Common event and notification subsystem| | static const std::string POWERMGR | Power management subsystem| | static const std::string ROUTER | Router subsystem| | static const std::string SECURITY | Security subsystem| | static const std::string SENSORS | Pan-sensor subsystem| | static const std::string SOURCE_CODE_TRANSFORMER | Application porting subsystem| | static const std::string STARTUP | Startup subsystem| | static const std::string TELEPHONY | Telephony subsystem| | static const std::string UPDATE | Update subsystem| | static const std::string USB | USB subsystem| | static const std::string WEARABLE_HARDWARE | Wearable-dedicated hardware subsystem| | static const std::string WEARABLE_HARDWARE | Wearable-dedicated service subsystem| | static const std::string OTHERS | Others| **Table 3** Description of HiSysEvent::EventType | Name| Description| | -------- | --------- | | FAULT | Fault event| | STATISTIC | Statistical event| | SECURITY | Security event| | BEHAVIOR | System behavior event| ### Development Example C++ 1. Develop the source code. Include the HiSysEvent header file in the class definition header file or class implementation source file. For example: ``` #include "hisysevent.h" ``` Add the event logging code. For example, if you want to log events specific to the app start time (start\_app), then add the following code to the service implementation source file: ``` HiSysEvent::Write(HiSysEvent::Domain::AAFWK, "start_app", HiSysEvent::EventType::FAULT, "app_name", "com.demo"); ``` 2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. ``` external_deps = [ "hisysevent_native:libhisysevent" ] ```