文件最后提交记录最后更新时间
!935 修复文件名大小写导致的打包失败问题 * update compile bug 3 年前
!839 修改Logger * fix up 3 年前
!845 翻译已完成 * update doc 3 年前
!964 README整改 * update readme 3 年前
!764 新增eTSLogger * fix up * fix up * fix up 3 年前
!764 新增eTSLogger * fix up * fix up * fix up 3 年前
!839 修改Logger * fix up 3 年前
README.md

Log

Introduction

This sample shows how to use log APIs to print log information and save the information to the application installation directory.

APIs

    import logger from '@ohos/log'
    import { LogLevel } from '@ohos/log'
    import { Configure }  from '@ohos/log'

Usage Instruction

  1. Configure log printing parameters.
  Configure = {
    cheese: {
        types: string[],
        filename: string
    }
    defaults: {
        appenders: string,
        level: LogLevel
    }
  } 
  // If types is set to file, logs are saved to the file named by filename. appenders indicates the log tag, and level indicates the lowest log level.
  1. Initialize a logger instance.
   logger.setConfigure(configure: Configure)
   // configure indicates the parameter configuration.
  1. Print log information of the debug level.
   logger.debug(value) 
   // value indicates the log content.
  1. Print log information of the info level.
   logger.info(value) 
   // value indicates the log content.
  1. Print log information of the warn level.
   logger.warn(value) 
   // value indicates the log content.
  1. Print log information of the error level.
   logger.error(value) 
   // value indicates the log content.
  1. Print log information of the fatal level.
   logger.fatal(value, bool) 
   // value indicates the log content.

Constraints

  1. This sample requires API version 8 or later.

  2. The DevEco Studio version used in this sample must be 3.0.0.900 or later.