log4android

Log4Android - Simple Logging Wrapper Library for Android

Tired writing TAG each time writing log in Android? Bored with printing variables by concatenating string with "+"??

Come from Java Enterprise Development where infamous Log4J used heavily??

Well, with this Log4Android library, you can easily write log with your old habit

log.debug("in myMethod, id={}, name={}", ver1, ver2);

You also can easily disable printing logs by calling method Logger.disableLogging(true). This specially

useful when you want to remove log printing while publishing app in playstore.

Features

Log syntax similar with popular log4j framework

Automatically added TAG with log message

Derive TAG from the package name

Can disable logging by simply calling Logger.disableLogging(true) method preferably from the class extends Application.

Fully Qualified Class name or SimpleClassName will logged as prefix with log message

Variable Arguments (more than 2) can be passed for printing unlike log4j framework

Very lightweight, < 5KB library size!

Quick Start

First, add Log4Android-x.x.jar (can download from releases directory) at your android project library

Obtain a logger object in your Android code (Activity, Fragment, Service etc) like:

private static final Logger log = Logger.getLogger(MyActivity.class);

OR

private static final Logger log = Logger.getLogger("YOUR_TAG");

OR

private static final Logger log = Logger.getLogger(MyActivity.class, "YOUR_TAG");

Now, start writing log like:

log.info("onStart(), id={}, someObject={}", id, someObject);

log.debug(tvName.getText());

log.verbose("var1={}, var2={}, var3={}, var4={}", v1, v2, v3, v4);

log.error(ex, "Error occur while trying to load image with id={}", id);

Also can pass throwable/exception as the last argument which will print accordingly:

log.error("Exception at row id={}", id, throwable);

API Docs

Motivation

No other library found for Android Development except "SLF4J Android", provide similar logging mechanism as standard

java logging framework. But "SLF4J Android" library has the following limitation:

SLF4J try to use full qualified class name as tag. This cause problem when, auto generated log tags that are

<= 23 characters long due to a length restriction of log tags on the Android platform (e.g., com.example.myapp.MyClass

tag translated to c*.e*.m*.MyClass), which can result in the same log tag for different classes

(e.g., com.example.app.MyClass and com.example.anotherapp.MyClass both translate to c*.e*.a*.MyClass);

So, sometimes, you can't distinguish classes. Besides, there is no other way to define your own TAG here.

Also log4j framework does not support variable arguments (more than 2) in a easy way, one have to write like new Object[]{var1, var2, var3} which I found annoying.

android log4,GitHub - oronno/log4android: Log4Android - Simple Logging Wrapper Library for Android相关推荐

  1. 鸿蒙霸榜GitHub,从最初的Plan B到“取代Android”?

    整理 | 郭芮 出品 | CSDN(ID:CSDNnews) 距离 8 月 9 日鸿蒙(HarmonyOS)正式发布刚刚过去九天,这场由华为领衔的技术风暴,经过十年蛰伏,终于成功引爆全球.与此同时,一 ...

  2. 开源需自立!Android、GitHub、Apache全线告急!

    作者 | 胡巍巍&伍杏玲 责编 | 唐小引 出品 | CSDN(ID:CSDNnews) 华为四面楚歌,"破窗效应"爆发! 继5月16日美国商务部工业与安全局(BIS)将华 ...

  3. EF Core使用Simple Logging输出日志

    在使用EF Core的时候,很多时候需要知道EF Core实际执行的SQL语句是什么. Simple Logging是EF Core提供的一项功能,可用于在开发和调试应用程序时轻松获取日志.这种形式的 ...

  4. Android使用Github Actions持续集成并自动上传apk到蒲公英App内测分发平台(含证书密码脱敏)

    目录 1.前言 2.Github Actions持续集成 3.上传apk到蒲公英 4.Gradle配合Github Actions的Secret使用 4.1设置Github Actions Secre ...

  5. 【Android】GitHub Android 开源项目汇总

    参考网址:http://blog.csdn.net/ithomer/article/details/8882236 GitHub 上的开源项目不胜枚举,越来越多的开源项目正在迁移到GitHub平台上. ...

  6. android tv github,GitHub - dongbingliu/Android-tv-widget: Android tv,盒子,投影仪 控件

    [前言] 因为要加强 Android 投影仪的 luncher 倒影国际化的功能,所以开始的时候在BroderView的基础改了些东西. 后来又一些BUG,修复了,感觉毕竟是用的别人的开源代码,如果不 ...

  7. brook android 客户端,GitHub - reaverbrook/android-app: 本项目已经迁移到 git.oschina.net ,此处不再更新!...

    android-app 开源中国社区 Android 客户端项目简析 注:本文假设你已经有Android开发环境 启动Eclipse,点击菜单并导入Android客户端项目,请确保你当前的Androi ...

  8. android pdf,GitHub - lidong1665/AndroidPDF

    ##1.基本思路: 打来网络pdf 思路整体还是来源与图片的加载. android中加载网络图片的框架有很多个.如image-laoder, fresco.glide等,首先都是从内存中找图片,如果内 ...

  9. Android NDK开发之旅(2):一篇文章搞定Android Studio中使用CMake进行NDK/JNI开发

    Android NDK开发之旅(2):一篇文章搞定android Studio中使用CMake进行NDK/JNI开发 (码字不易,转载请声明出处:http://blog.csdn.NET/andrex ...

最新文章

  1. bLock 回调 就是这么简单!
  2. python 流式编程_使用Python在两台计算机之间流式传输实时视频
  3. 胶囊网络全新升级!引入自注意力机制的Efficient-CapsNet
  4. mysql5.7 修改密码
  5. 信息学奥赛一本通(1136:密码翻译)
  6. R中双表操作学习[转载]
  7. Here we are 团队简介
  8. 通过实例学习编写需求文档 【转】
  9. Callback、Listener、Worker、Manager的命名说明
  10. php全表搜索,搜索整个表? PHP MySQL
  11. verilog学习笔记——8位数码管驱动设计与验证
  12. nginx通过url跳转到另外的一个url上
  13. 横向移动-WINRM
  14. temp不停生成临时文件 win10_c盘temp文件夹自动生成大量TMP文件。
  15. 中国中老年服装市场投资前景分析及供需格局研究预测报告
  16. em表示什么长度单位_css中pt、px、em、ex、in等这类长度单位详细说明
  17. 计算机国际会议开幕词,国际学术会议开幕词.doc
  18. Android studio校园通 社区活动 新闻 组织结构 日历
  19. 重装系统后只有一个盘了别的盘的文件如何找回
  20. android百度输入法源码,Android系统预置百度输入法

热门文章

  1. 服务器 kvm 进入系统,服务器CAT5 KVM切换器系统
  2. python爬取图片全网通_UC头条:全网通杀——暴强工具推荐: 下载你看到的任意视频...
  3. mysql makefile_编译安装mysql,找不到makefile
  4. js控制鼠标移动_原生JS封装可拖拽效果
  5. java中的main的介绍_Java中的main函数详细讲解
  6. 迷宫python_Python走迷宫,递归 - nixBlog
  7. ajax传formdata类型的数据_JQuery.Ajax()的data参数类型
  8. laravel5.5的定时任务详解(demo)
  9. python【力扣LeetCode算法题库】300 最长上升子序列(动态规划)
  10. python【蓝桥杯vip练习题库】ALGO-1区间k大数查询