1600cc4afSopenharmony_ci## How To Use Log
2600cc4afSopenharmony_ci
3600cc4afSopenharmony_ci# C++
4600cc4afSopenharmony_ci1. Add a statement to your gn file
5600cc4afSopenharmony_ci
6600cc4afSopenharmony_ci```
7600cc4afSopenharmony_ci    deps = [
8600cc4afSopenharmony_ci        "${common_path}/log:appexecfwk_log_source_set",
9600cc4afSopenharmony_ci    ]
10600cc4afSopenharmony_ci
11600cc4afSopenharmony_ci    defines = [
12600cc4afSopenharmony_ci        "APP_LOG_TAG = \"Appexecfwk_Core\"",
13600cc4afSopenharmony_ci        "LOG_DOMAIN = 0xD001110",
14600cc4afSopenharmony_ci    ]
15600cc4afSopenharmony_ci```
16600cc4afSopenharmony_ci2. Include header file `#include "app_log_wrapper.h"`
17600cc4afSopenharmony_ci3. Control log print level `AppLogWrapper::SetLogLevel(AppLogLevel::DEBUG);` default is DEBUG
18600cc4afSopenharmony_ci4. Example output format `[fileName(functionName)] string`
19600cc4afSopenharmony_ci```
20600cc4afSopenharmony_ci    // dynamic control log level
21600cc4afSopenharmony_ci    AppLogWrapper::SetLogLevel(AppLogLevel::FATAL);
22600cc4afSopenharmony_ci
23600cc4afSopenharmony_ci    // The following log statement will not print
24600cc4afSopenharmony_ci    APP_LOGD("one %{public}d", 1234);
25600cc4afSopenharmony_ci    APP_LOGI("two %{public}s", "1234");
26600cc4afSopenharmony_ci    APP_LOGW("three %{private}s", "1234");
27600cc4afSopenharmony_ci    APP_LOGE("four %{private}s", "1234");
28600cc4afSopenharmony_ci
29600cc4afSopenharmony_ci    // The following log statement will print
30600cc4afSopenharmony_ci    AppLogWrapper::SetLogLevel(AppLogLevel::DEBUG);
31600cc4afSopenharmony_ci    APP_LOGD("five %{public}d", 1234);
32600cc4afSopenharmony_ci    APP_LOGI("six %{public}s", "1234");
33600cc4afSopenharmony_ci    APP_LOGW("seven %{private}s", "1234");
34600cc4afSopenharmony_ci    APP_LOGE("eight %{private}s", "1234");
35600cc4afSopenharmony_ci```
36600cc4afSopenharmony_ci
37600cc4afSopenharmony_ci# Java
38600cc4afSopenharmony_ci
39600cc4afSopenharmony_ci1. import dependent in your class
40600cc4afSopenharmony_ci```
41600cc4afSopenharmony_ciimport ohosos.appexecfwk.utils.AppLog;
42600cc4afSopenharmony_ciimport ohosos.hiviewdfx.HiLogLabel;
43600cc4afSopenharmony_ci```
44600cc4afSopenharmony_ci
45600cc4afSopenharmony_ci2. custom HiLogLabel (if you don't custom label, the default will be used)
46600cc4afSopenharmony_ci```
47600cc4afSopenharmony_ciprivate static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_CORE, 0xD001110, "AppKit");
48600cc4afSopenharmony_ci```
49600cc4afSopenharmony_ci
50600cc4afSopenharmony_ci3. use AppLog interface
51600cc4afSopenharmony_ci```
52600cc4afSopenharmony_ciApp_Log.d(LABEL, "log %{public}s", "123");
53600cc4afSopenharmony_ciApp_Log.i("log %{public}d", 123);
54600cc4afSopenharmony_ci```