Log Guide for Harmony OS Apps on DevEco Studio IDE-Part 1

Barıs Can Kurtulmus
Huawei Developers
Published in
4 min readNov 3, 2021

What is DevEco Studio?

DevEco Studio provides a proper environment for the development of apps, quick apps, and smart devices for the HUAWEI 1+8+N ecosystem and distributed OS, with the help of desktop IDEs and various cloud services.

DevEco Studio Desktop IDE

Introduction

In this article, I will explain how to create and view different types of logs for the following gadgets on DevEco Studio IDE :

  • Simulators (lite wearable & smart TV)
  • real Harmony OS Device connection (wearable & smartphone)

Simulators

Create console logs

If you want to observe changes through logs when you run & debug(test) your lite wearable(ex: Huawei gt2 pro watch) or Smart TV application on their Dev ECO Studio simulators, console logs(1) can be used as below :

For further information please check this link.

View Console Logs

Two different ways to check/view the harmony OS app console logs for simulators:

  1. Checking a previewer.log file content for logs at the following directory in your system : C:\Users\<Username>\ AppData\ Local\ Huawei\ DevEcoStudio2.1\log

Note: simulator.log file (at the same directory path) used for IDE’s own debugging and protocol logs. It does not record the running simulator’s logs.

2. Checking console logs on DEV Eco Studio IDE interface

If you Run the project on the lite wearable simulator, Run console logs viewed as:

If you Debug the project on the lite wearable simulator, Debug console logs are viewed as:

If you Preview the project on Dev Eco Studio previewer, Preview logs are viewed as:

For further details about the console logs check this link.

Real Harmony OS Devices

You can similarly Create console logs and View Console Logs for Real Harmony OS Devices as specified in the previous section for simulators.

Step1: Connect your Harmony OS device to your PC using USB debugging or WI-FI debugging based on supported specs of the device and ensure that it is detected by Dev ECO Studio IDE.

Connected Huawei Watch Device on Dev ECO Studio IDE

Please check this link for detailed information on device connection steps.

Create console logs

Create console info-specific log as done similarly for simulators

var versionCode = 1;
console.info('Hello World. The current version code is ' + versionCode);

View Console Logs

View console info-specific log on HiLog submenu by choosing a current device, process, and set log level to Info. Then enter Hello World in the search box.

Example 1 on Huawei Vision X65 smart TV
Example 2 on Huawei Watch 3

Create HiLogs

HiLog capability of HarmonyOS helps your applications to output logs based on the specified type, level, and format string. Such logs help you learn the running status of applications and better debug programs.

Note: The APIs of this module are supported since JS API version 7.

Js API version 7 code:

Java API older version code:

View HiLogs

JS API version 7 Hilog Log Viewing on Device Status: Currently Not Available

Note: For the JS API version 7 project log to be viewed on DEV Eco Studio, you need a device that supports API version 7. It is currently(Nov 2021) not supported by any Harmony OS device in the market. But there is a future plan. For JAVA API's previous versions, it is already released and can be used by specific devices.

JAVA API previous version Hilog Log Viewing(2)(3) on Device Status: Available

View JAVA API Hilog warning-specific log on HiLog submenu by choosing a current device, process, and set the log level to Warning. Then enter service domain number “00201” in the search box.

Conclusion

This is the first part of the article series that gives an introductory idea to Harmony OS developers about creating and viewing HiLogs & console logs using Dev Eco Studio Desktop IDE. In the next parts, HiTrace Log Tracing, Cross-device debugging(distributed app log) concepts will be introduced.

References

1-) Console Log Documentation of official Harmony OS Website

2-) For further details about HiLog

3-) For further details about HiLog

--

--