{"id":3566,"url":"https://github.com/orhanobut/logger","last_synced_at":"2025-05-13T00:12:25.984Z","repository":{"id":29082163,"uuid":"32610336","full_name":"orhanobut/logger","owner":"orhanobut","description":"✔️ Simple, pretty and powerful logger for android","archived":false,"fork":false,"pushed_at":"2022-09-14T10:04:00.000Z","size":1873,"stargazers_count":13862,"open_issues_count":81,"forks_count":2141,"subscribers_count":368,"default_branch":"master","last_synced_at":"2025-05-13T00:12:18.863Z","etag":null,"topics":["android","java","json-logging","log","logcat","logger","pretty-printer","timber"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orhanobut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-20T22:30:12.000Z","updated_at":"2025-05-12T00:53:33.000Z","dependencies_parsed_at":"2022-07-14T03:20:39.778Z","dependency_job_id":null,"html_url":"https://github.com/orhanobut/logger","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhanobut%2Flogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhanobut%2Flogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhanobut%2Flogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orhanobut%2Flogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orhanobut","download_url":"https://codeload.github.com/orhanobut/logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843219,"owners_count":21972874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","java","json-logging","log","logcat","logger","pretty-printer","timber"],"created_at":"2024-01-05T20:16:45.129Z","updated_at":"2025-05-13T00:12:25.937Z","avatar_url":"https://github.com/orhanobut.png","language":"Java","readme":"[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Logger-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/1658) [![](https://img.shields.io/badge/AndroidWeekly-%23147-blue.svg)](http://androidweekly.net/issues/issue-147)\n[![Join the chat at https://gitter.im/orhanobut/logger](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/orhanobut/logger?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge) \u003ca href=\"http://www.methodscount.com/?lib=com.orhanobut%3Alogger%3A2.0.0\"\u003e\u003cimg src=\"https://img.shields.io/badge/Methods and size-198 | 18 KB-e91e63.svg\"/\u003e\u003c/a\u003e [![Build Status](https://travis-ci.org/orhanobut/logger.svg?branch=master)](https://travis-ci.org/orhanobut/logger)\n\n\u003cimg align=\"right\" src='https://github.com/orhanobut/logger/blob/master/art/logger-logo.png' width='128' height='128'/\u003e\n\n### Logger\nSimple, pretty and powerful logger for android\n\n### Setup\nDownload\n```groovy\nimplementation 'com.orhanobut:logger:2.2.0'\n```\n\nInitialize\n```java\nLogger.addLogAdapter(new AndroidLogAdapter());\n```\nAnd use\n```java\nLogger.d(\"hello\");\n```\n\n### Output\n\u003cimg src='https://github.com/orhanobut/logger/blob/master/art/logger_output.png'/\u003e\n\n\n### Options\n```java\nLogger.d(\"debug\");\nLogger.e(\"error\");\nLogger.w(\"warning\");\nLogger.v(\"verbose\");\nLogger.i(\"information\");\nLogger.wtf(\"What a Terrible Failure\");\n```\n\nString format arguments are supported\n```java\nLogger.d(\"hello %s\", \"world\");\n```\n\nCollections are supported (only available for debug logs)\n```java\nLogger.d(MAP);\nLogger.d(SET);\nLogger.d(LIST);\nLogger.d(ARRAY);\n```\n\nJson and Xml support (output will be in debug level)\n```java\nLogger.json(JSON_CONTENT);\nLogger.xml(XML_CONTENT);\n```\n\n### Advanced\n```java\nFormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()\n  .showThreadInfo(false)  // (Optional) Whether to show thread info or not. Default true\n  .methodCount(0)         // (Optional) How many method line to show. Default 2\n  .methodOffset(7)        // (Optional) Hides internal method calls up to offset. Default 5\n  .logStrategy(customLog) // (Optional) Changes the log strategy to print out. Default LogCat\n  .tag(\"My custom tag\")   // (Optional) Global tag for every log. Default PRETTY_LOGGER\n  .build();\n\nLogger.addLogAdapter(new AndroidLogAdapter(formatStrategy));\n```\n\n### Loggable\nLog adapter checks whether the log should be printed or not by checking this function.\nIf you want to disable/hide logs for output, override `isLoggable` method. \n`true` will print the log message, `false` will ignore it.\n```java\nLogger.addLogAdapter(new AndroidLogAdapter() {\n  @Override public boolean isLoggable(int priority, String tag) {\n    return BuildConfig.DEBUG;\n  }\n});\n```\n\n### Save logs to the file\n//TODO: More information will be added later\n```java\nLogger.addLogAdapter(new DiskLogAdapter());\n```\n\nAdd custom tag to Csv format strategy\n```java\nFormatStrategy formatStrategy = CsvFormatStrategy.newBuilder()\n  .tag(\"custom\")\n  .build();\n  \nLogger.addLogAdapter(new DiskLogAdapter(formatStrategy));\n```\n\n### How it works\n\u003cimg src='https://github.com/orhanobut/logger/blob/master/art/how_it_works.png'/\u003e\n\n\n### More\n- Use filter for a better result. PRETTY_LOGGER or your custom tag\n- Make sure that wrap option is disabled\n- You can also simplify output by changing settings.\n\n\u003cimg src='https://github.com/orhanobut/logger/blob/master/art/logcat_options.png'/\u003e\n\n- Timber Integration\n```java\n// Set methodOffset to 5 in order to hide internal method calls\nTimber.plant(new Timber.DebugTree() {\n  @Override protected void log(int priority, String tag, String message, Throwable t) {\n    Logger.log(priority, tag, message, t);\n  }\n});\n```\n\n### License\n\u003cpre\u003e\nCopyright 2018 Orhan Obut\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\u003c/pre\u003e\n","funding_links":[],"categories":["Logger","Java","Libraries","Android 应用","Index",":shamrock:  **Categories**","日志库"],"sub_categories":["Logger","网络服务_其他","Logging",":books: Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forhanobut%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forhanobut%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forhanobut%2Flogger/lists"}