How Bugly Transforms HarmonyOS Logging with Xlog for Enterprise‑Level Diagnostics
This article explains how Bugly leverages the open‑source Xlog kernel to overcome HarmonyOS native logging limitations, offering a comprehensive, cross‑platform log engine, diagnostic fetch module, and practical scenarios that boost issue diagnosis, dynamic log control, privacy, and developer productivity.
1. Pain Points and Challenges of HarmonyOS Native Log System
Although the native HiLog tool is comparable to Android Logcat in printing and local debugging, developers still face several issues:
Online debugging difficulty: lack of remote log collection makes reproducing and locating issues hard.
Log fragmentation: third‑party SDK logs, system logs and business logs are mixed.
Print length limit: HiLog truncates long messages, losing key information.
2. Bugly’s HarmonyOS Log Diagnosis Adaptation
Bugly adapts the open‑source Xlog kernel from WeChat and combines platform diagnostic capabilities to provide a complete enterprise‑level log solution for HarmonyOS NEXT.
TDLog (log engine): based on high‑performance Xlog, offers local logging via mmap and streaming compression.
Source code references: cloud.tencent.com article , Tencent Mars repository .
Adaptation steps:
Compile script adaptation – Xlog is built with CMake, same as HarmonyOS native compilation.
Source logic adaptation – integrate OpenSSL built with HarmonyOS toolchain and handle platform differences.
ArkTS layer wrapping and bridging – expose NAPI interfaces for log creation, flushing and configuration.
3. TDDiag (diagnostic fetch) Module
TDDiag works independently from TDLog, providing log upload, fetch, and coloring services. It consists of a backend for storage, decryption and command distribution, and an SDK for reporting, configuration pulling and remote log level control.
4. Application Scenarios
Scenario 1 – Faster online issue diagnosis: platform issues a fetch command, SDK pulls configuration, packages logs and uploads; Bugly also supports one‑click log fetch for the hour before an exception and AI‑based log analysis.
Scenario 2 – Dynamic log level adjustment: create coloring tasks on the Bugly console, devices receive the config and adjust log levels, then upload or fetch detailed logs.
Scenario 3 – Clear log layering: create separate log instances for third‑party SDKs or business modules, use native APIs for efficient logging without ArkTS bridging.
Scenario 4 – Log privacy and security: line‑by‑line encryption via Xlog’s streaming compression, with automatic decryption on the Bugly platform.
Bugly’s HarmonyOS log SDK is free for HarmonyOS developers and can be integrated alongside existing logging solutions. Integration documentation: Bugly Harmony SDK .
Tencent TDS Service
TDS Service offers client and web front‑end developers and operators an intelligent low‑code platform, cross‑platform development framework, universal release platform, runtime container engine, monitoring and analysis platform, and a security‑privacy compliance suite.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
