# EtherCAT® traffic logging in application [`emLogFrameEnable()`](api_diagnosis.html.md#_CPPv416emLogFrameEnable10EC_T_DWORD18EC_T_PFLOGFRAME_CBP9EC_T_VOID) [`emLogFrameDisable()`](api_diagnosis.html.md#_CPPv417emLogFrameDisable10EC_T_DWORD) All network traffic can be recorded by starting EcMasterDemo with the parameter `-rec`. For this `EcMasterDemo` needs to be compiled with preprocessor definition INCLUDE_PCAP_RECORDER defined. See `class CPcapRecorder` in `EcLogging.h/cpp`. ### **EtherCAT**® **traffic logging Example** ```cpp EC_T_VOID /* EC_FNCALL */ LogFrameHandler(EC_T_VOID* /* pvContext */, EC_T_DWORD dwLogFlags, EC_T_DWORD dwFrameSize, EC_T_BYTE* pbyFrame) { EC_T_WORD wFrameType = EC_ETHFRM_GET_FRAMETYPE(pbyFrame); EcLogMsg(EC_LOG_LEVEL_VERBOSE_CYC, (pEcLogContext, EC_LOG_LEVEL_VERBOSE_CYC, "%d: LogFrameHandler(): Type: 0x%04X (%s, %s %s), length: %d bytes\n", wFrameType, ((0 != (dwLogFlags & EC_LOG_FRAME_FLAG_RED_FRAME)) ? "RED" : "MAIN"), ((0 != (dwLogFlags & EC_LOG_FRAME_FLAG_RX_FRAME)) ? "RX" : "TX"), ((0 != (dwLogFlags & EC_LOG_FRAME_FLAG_ACYC_FRAME)) ? "acyclic" : "cyclic"), dwFrameSize)); } ``` ```cpp /* setup callback function to log EtherCAT network traffic */ EC_T_VOID* pvMyAppContext = this; dwRes = emLogFrameEnable(dwInstanceId, LogFrameHandler, pvMyAppContext); ``` ```cpp /* disable frame logging callback */ dwRes = emLogFrameDisable(dwInstanceId); ```