{"id":17241778,"url":"https://github.com/j256/simplelogging","last_synced_at":"2025-07-31T05:09:32.572Z","repository":{"id":45088318,"uuid":"321776820","full_name":"j256/simplelogging","owner":"j256","description":"Simple Java logging facade which can backend into a number of different logging implementations and is designed to be copied into another project.","archived":false,"fork":false,"pushed_at":"2025-02-22T22:07:23.000Z","size":1417,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T03:15:01.800Z","etag":null,"topics":["facade","java","logging","logging-library"],"latest_commit_sha":null,"homepage":"https://256stuff.com/sources/simplelogging/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/j256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","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,"zenodo":null},"funding":{"github":"j256","patreon":"j256"}},"created_at":"2020-12-15T20:06:13.000Z","updated_at":"2025-02-22T22:07:26.000Z","dependencies_parsed_at":"2024-02-04T22:22:16.102Z","dependency_job_id":"4b63b2cf-8979-42b7-8c07-867104621870","html_url":"https://github.com/j256/simplelogging","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/j256/simplelogging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j256%2Fsimplelogging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j256%2Fsimplelogging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j256%2Fsimplelogging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j256%2Fsimplelogging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j256","download_url":"https://codeload.github.com/j256/simplelogging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j256%2Fsimplelogging/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267989020,"owners_count":24177020,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["facade","java","logging","logging-library"],"created_at":"2024-10-15T06:11:18.166Z","updated_at":"2025-07-31T05:09:32.529Z","avatar_url":"https://github.com/j256.png","language":"Java","readme":"Java Simple Logging Package\n===========================\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.j256.simplelogging/simplelogging/badge.svg?style=flat-square)](https://mvnrepository.com/artifact/com.j256.simplelogging/simplelogging/latest)\n[![javadoc](https://javadoc.io/badge2/com.j256.simplelogging/simplelogging/javadoc.svg)](https://javadoc.io/doc/com.j256.simplelogging/simplelogging)\n[![ChangeLog](https://img.shields.io/github/v/release/j256/simplelogging?label=changelog\u0026display_name=release)](https://github.com/j256/simplelogging/blob/master/src/main/javadoc/doc-files/changelog.txt)\n[![Documentation](https://img.shields.io/github/v/release/j256/simplelogging?label=documentation\u0026display_name=release)](https://htmlpreview.github.io/?https://github.com/j256/simplelogging/blob/master/src/main/javadoc/doc-files/simplelogging.html)\n[![CodeCov](https://img.shields.io/codecov/c/github/j256/simplelogging.svg)](https://codecov.io/github/j256/simplelogging/)\n[![CircleCI](https://circleci.com/gh/j256/simplelogging.svg?style=shield)](https://circleci.com/gh/j256/simplelogging)\n[![GitHub License](https://img.shields.io/github/license/j256/simplelogging)](https://github.com/j256/simplelogging/blob/master/LICENSE.txt)\n\nThe goal of this library is to be a small logging facade that backends to a number of standard logging packages and that\ncan be copied into another project.  This allows you to write your code and include log messages without having a fixed\ndependency on any one logging package.  I include this code into my libraries and so they can stay agnostic.  This\nlogging code allows you to write messages with the slf4j-style `{}` argument support, handles arrays appropriately, and\nsupports up to 4 arguments before forcing the caller to pass in an object array or calling a different `logArgs(...)`\nmethod for variable arguments.  It also supports \"fluent\" logging where you can chain log methods together to build your\nlog message which generates no objects if the log level is not enabled.\n\nThis library is similar to other logging systems which separate the API from the logging implementation. SimpleLogging\nis better than the others because it calls directly to specific backend APIs which can be chosen through code or\nconfiguration. this direct calling allows for more control over the backend selection and usually fewer dependencies.\n\nSimpleLogging is also designed to be copied into your open source project so you don't have to add a maven dependency.\nJust copy the java files from ``src/main/java`` into your source tree and rename the packages as necessary.  Please also\ncopy the ``SIMPLELOGGING_LICENSE.txt`` file which is the very permissive ISC license.  You may want to change the\nconstants in ``LoggerConstants.java``.\n\n* The source code be found on the [git repository](https://github.com/j256/simplelogging)\n* Maven packages are published via [Maven Central](https://mvnrepository.com/artifact/com.j256.simplelogging/simplelogging/latest)\n* [Documentation for the library](https://htmlpreview.github.io/?https://github.com/j256/simplelogging/blob/master/src/main/javadoc/doc-files/simplelogging.html).  More on the [home page](https://256stuff.com/sources/simplelogging/).\n* [Javadoc documentation](https://javadoc.io/doc/com.j256.simplelogging/simplelogging)\n\nEnjoy.  Gray Watson\n\n# Supported Logging Backends\n\nThe following logging implementations will be discovered in this order.  You can also select a machine through\ncode or configuration.\n\n1. Android native Log\n2. Logback directly (using slf4j-api)\n3. LOG4J2 (version 2+)\n4. LOG4J (older, accessed only through reflection if already on the classpath so no dependencies)\n5. AWS lambda logging.\n6. SLF4J (often paired with logback)\n8. Apache Commons Logging\n8. Local log implementation that can write to a simple file.\n9. Simple console output.\n10. Java util logging which is usually available in the JRE but never chosen directly. \n\n[Backend discovery documentation](https://256stuff.com/sources/simplelogging/docs/backend-discovery)\n\n# Getting Started\n\nTo get started you instantiate a `Logger` using the `LoggerFactory`:\n\n```java\n// usually a logger will be per-class, getLogger() also can take a String label\nprivate static final Logger logger = LoggerFactory.getLogger(MyClass.class);\n...\n// log trace message with arguments\n// toString() on the args is only called if trace messages is enabled\nlogger.trace(\"some trace information: {} and {}\", arg1, arg2);\n...\n// NOTE: exception argument comes _before_ the message format to not confuse the arguments\nlogger.error(exception, \"http client threw getting URL: {}\", url);\n```\n\n[Getting started documentation](https://256stuff.com/sources/simplelogging/docs/getting-started)\n\n# \"Fluent\" Logging with Method Chaining Supported\n\nSimpleLogging also supports \"fluent\" logging where you can chain log methods together to build your\nlog message which will generate no objects if the log level is not enabled.  For example, even with\nport being an `int` primitive below, there are no objects generated by thus call unless `TRACE` log\nlevel is enabled.\n\n```java\nprivate static final FluentLogger fluentLogger =\n    LoggerFactory.getFluentLogger(MyClass.class);\n...\n// this generates no objects even due to auto-boxing unless trace is enabled\nfluentLogger.atLevel(Level.TRACE)\n    .msg(\"connected to host '{}' port '{}'\")\n    .arg(host)\n    .arg(port)\n    .log();\n```\n\n[Fluent logging documentation](https://256stuff.com/sources/simplelogging/docs/fluent-logging)\n\n# Examples of Argument Processing\n\nHere are some more examples showing the details about the argument logic:\n\n```java\nprivate static final Logger logger = LoggerFactory.getLogger(MyClass.class);\n...\n\n// no arguments but a {} pattern\nlogger.info(\"connected to host '{}'\");\n// outputs: connected to host '{}'\n\n// missing argument to second {} displays as empty string\nString host = \"host1\";\nlogger.info(\"connected to host '{}' port '{}'\", host);\n// outputs: connected to host 'host1' port ''\n\n// extra argument (port) is ignored\nString host = \"host1\";\nint port = 443;\nlogger.info(\"connected to host '{}'\", host, port);\n// outputs: connected to host 'host1'\n\n// null argument\nString host = null;\nlogger.info(\"connected to host '{}' failed\", host);\n// outputs: connected to host 'null'\n\n// arguments that are arrays\nString[] hosts = new String[] { \"srv1\", \"srv2\" };\nlogger.info(\"connected to hosts {} failed\", hosts);\n// outputs: connected to hosts [srv1, srv2]\n\n// logging of Host which implements LogArgumentCreator where\n// host.createLogArg() method returns the string: host4\nHost host = new Host();\nlogger.info(\"connected to host '{}'\", host);\n// outputs: connected to host 'host4'\n\n// logging of Server where server.toString() returns: srv3\nServer server = new Server();\nlogger.info(\"connected to host '{}'\", server);\n// outputs: connected to host 'srv3'\n```\n\n# Maven Configuration\n\nMaven packages are published via [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.j256.simplelogging/simplelogging/badge.svg?style=flat-square)](https://mvnrepository.com/artifact/com.j256.simplelogging/simplelogging/latest)\n\n``` xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.j256.simplelogging\u003c/groupId\u003e\n\t\u003cartifactId\u003esimplelogging\u003c/artifactId\u003e\n\t\u003cversion\u003e3.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n# Dependencies\n\nSimpleLogging has no direct dependencies.  It has a number of optional dependencies that will only be referenced if\nthey are already in your application's classpath.\n\n# ChangeLog Release Notes\n\nSee the [![ChangeLog](https://img.shields.io/github/v/release/j256/simplelogging?label=changelog)](https://github.com/j256/simplelogging/blob/master/src/main/javadoc/doc-files/changelog.txt)\n","funding_links":["https://github.com/sponsors/j256","https://patreon.com/j256"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj256%2Fsimplelogging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj256%2Fsimplelogging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj256%2Fsimplelogging/lists"}