Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
R repo_manifest
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • cobalt
  • repo_manifest
  • Wiki
  • logging

Last edited by Mark Stevens Jul 09, 2018
Page history

logging

Overview

Android has a build-in logging utility, android.util.Log, which is a jni connect to a c-compiler logging system. The system uses a rotation of files of a designated size. Both the size and the number of log files in rotation are configurable.

The Log calls take a String for a Tag, a String for the message and an optional Exception object. There is an isLoggable() call which can be used to eliminate costly string concatenation calls when the log calls should be ignored. Unfortunately this optimazation is often overlooked by devs. It is both cumbersome and it clutters up code even further.

SLF4j is a logger implementation that is designed to resolve some of the working issues with loggers. The implementation consists of a standardized api and an android specific implementation.

The android impl still uses the base android Logging utility, but with a few key improvements. The calls automatically respect the isLoggable() status, and the messages can be formatted in a printf style, where arguments are referred to positionally with '{}' and the actual argument objects are tacked onto the end of the log call. SLF4j checks the isLoggable() status and if the message should not be logged, all string processing is avoided.

isLoggable(TAG, LEVEL) translates to an OS level check of a system property named as log.tag., where is the under 23 char tag to be checked for. Through adb the tags and their levels can be modified using set prop log.tag.<TAG> D|I|V|S

In the event the message should be logged, each object that is not null has it's toString() function called and is inserted into the format string. After processing, the message is sent to the android log util for stock processing.

In practice, this looks like : static Logger logger = LoggerFactory.getLogger("TAG"); ... logger.debug( "log event= arg1:{}, arg2:{}, arg3:{}", arg1, arg2, arg3 );

Clone repository
  • build stories
  • dev stories
  • fitness testing
  • handshake
  • Home
  • logging
  • provisioning
  • rockchip parameter file format v1.3 (en)
  • secure boot application note
  • secure provisioning
  • sitehub hardening
  • tee readme
  • tee