{"id":20287084,"url":"https://github.com/devcsrj/slf4j-okhttp3-logging-interceptor","last_synced_at":"2025-04-11T09:40:41.552Z","repository":{"id":84465051,"uuid":"82247880","full_name":"devcsrj/slf4j-okhttp3-logging-interceptor","owner":"devcsrj","description":"An OkHttp logging interceptor for Slf4j loggers","archived":false,"fork":false,"pushed_at":"2017-12-27T15:01:23.000Z","size":33,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T06:40:35.504Z","etag":null,"topics":["logging","okhttp3","slf4j"],"latest_commit_sha":null,"homepage":null,"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/devcsrj.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-17T02:23:05.000Z","updated_at":"2022-12-21T13:47:03.000Z","dependencies_parsed_at":"2023-03-08T09:15:25.732Z","dependency_job_id":null,"html_url":"https://github.com/devcsrj/slf4j-okhttp3-logging-interceptor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devcsrj%2Fslf4j-okhttp3-logging-interceptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devcsrj%2Fslf4j-okhttp3-logging-interceptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devcsrj%2Fslf4j-okhttp3-logging-interceptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devcsrj%2Fslf4j-okhttp3-logging-interceptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devcsrj","download_url":"https://codeload.github.com/devcsrj/slf4j-okhttp3-logging-interceptor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248369033,"owners_count":21092511,"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":["logging","okhttp3","slf4j"],"created_at":"2024-11-14T14:38:06.451Z","updated_at":"2025-04-11T09:40:41.536Z","avatar_url":"https://github.com/devcsrj.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slf4j Logging Interceptor\n\nAn [OkHttp interceptor][1] which logs HTTP request and response data to an [slf4j logger](http://www.slf4j.org/).\n\n```java\nOkHttpClient client = new OkHttpClient.Builder()\n  .addInterceptor(new HttpLoggingInterceptor())\n  .build();\n```\n\nYou can change the log level at any time on your corresponding logging configuration. For example, in [log4j](https://logging.apache.org/log4j/2.x/) you'll use:\n\n```\nlog4j.logger.okhttp3.logging.wire=DEBUG\n```\nThe interceptor logs based from the following rules:\n\n- `DEBUG` - request and response lines and their respective headers and bodies\n- `INFO` - request and response lines and their respective headers\n- `ERROR`/`WARN` - none\n\n## Customization\n\nTo log to a custom location, pass a `Logger` instance to the constructor.\n\n```java\nprivate static final Logger yourLogger = LoggerFactory.getLogger( YourClass.class );\n\n...\n\nHttpLoggingInterceptor logging = new HttpLoggingInterceptor( yourLogger );\n```\n\n\u003e Don't forget to update your logging properties as well!\n\n**Warning**: The logs generated by this interceptor when using the `DEBUG` or `INFO` levels has the potential to leak sensitive information such as \"Authorization\" or \"Cookie\" headers and the contents of request and response bodies. This data should only be logged in a controlled way or in a non-production environment.\n\nAt `DEBUG` level, the interceptor by default loads the **entire** response body prior logging. This ensures that the `ResponseBody` is kept readable after the interceptor is finished. On cases where the expected content is huge, you can limit the size through one of it's constructor arguments:\n\n```java\n    new HttpLoggingInterceptor( yourLogger, 4096L );\n```\n\n## Downloading\n\nGet via Maven:\n\n```xml\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n          \u003cgroupId\u003ecom.github.devcsrj\u003c/groupId\u003e\n          \u003cartifactId\u003eslf4j-okhttp3-logging-interceptor\u003c/artifactId\u003e\n          \u003cversion\u003e1.0.1\u003c/version\u003e\n        \u003c/dependency\u003e\n        ...\n    \u003c/dependencies\u003e\n```\n\nor via Gradle\n\n```groovy\n   dependencies {\n        compile 'com.github.devcsrj:slf4j-okhttp3-logging-interceptor:1.0.1'\n   }\n```\n\n[1]: https://github.com/square/okhttp/wiki/Interceptors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevcsrj%2Fslf4j-okhttp3-logging-interceptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevcsrj%2Fslf4j-okhttp3-logging-interceptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevcsrj%2Fslf4j-okhttp3-logging-interceptor/lists"}