{"id":15010200,"url":"https://github.com/clojure/tools.logging","last_synced_at":"2025-05-15T00:06:36.362Z","repository":{"id":44568496,"uuid":"1468280","full_name":"clojure/tools.logging","owner":"clojure","description":"Clojure logging API","archived":false,"fork":false,"pushed_at":"2024-07-15T17:54:41.000Z","size":285,"stargazers_count":389,"open_issues_count":0,"forks_count":51,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-05-11T13:17:23.754Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clojure.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2011-03-11T15:01:29.000Z","updated_at":"2025-04-20T10:19:45.000Z","dependencies_parsed_at":"2024-02-19T17:52:33.432Z","dependency_job_id":"5cb49ddc-c627-4df6-bb99-da753ba63d74","html_url":"https://github.com/clojure/tools.logging","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Ftools.logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Ftools.logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Ftools.logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Ftools.logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clojure","download_url":"https://codeload.github.com/clojure/tools.logging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249198,"owners_count":22039029,"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":[],"created_at":"2024-09-24T19:32:06.556Z","updated_at":"2025-05-15T00:06:36.265Z","avatar_url":"https://github.com/clojure.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logging\n\nLogging macros which delegate to a specific logging implementation, selected\nat runtime when the `clojure.tools.logging` namespace is first loaded.\n\n## Installation\n\nLastest stable release is [1.3.0]\n\n[CLI/`deps.edn`](https://clojure.org/reference/deps_edn) dependency information:\n```clojure\norg.clojure/tools.logging {:mvn/version \"1.3.0\"}\n```\n\nLeiningen:\n\n```clojure\n[org.clojure/tools.logging \"1.3.0\"]\n```\n\nMaven:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.clojure\u003c/groupId\u003e\n  \u003cartifactId\u003etools.logging\u003c/artifactId\u003e\n  \u003cversion\u003e1.3.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n\n[Latest API Documentation](https://clojure.github.io/tools.logging)\n\nLogging occurs with the `log` macro, or the level-specific convenience macros\n(e.g., `debug`, `debugf`). Only when the specified logging level is enabled will\nthe message arguments be evaluated and the underlying logging implementation be\ninvoked. By default, that invocation will occur via an agent when inside a\nrunning STM transaction.\n\n### Namespacing of log entries\n\nUnless otherwise specified, the current namespace (as identified by `*ns*`) will\nbe used as the \"logger name\" when interacting with logging implementations. Most\nlogging implementations allow for varying configuration by logger name.\n\nNote: You should configure your logging implementation to display the logger\nname that was passed to it. If instead the logging implementation performs\nstack-inspection you'll see some ugly and unhelpful text in your logs.\n\n### Redirecting output to logs\n\nYou can redirect all java writes of `System.out` and `System.err` to the log\nsystem by calling `log-capture!`.  To bind `*out*` and `*err*` to the log system\ninvoke `with-logs`.  In both cases a logger name must be provided in lieu of\nusing `*ns*`.\n\n## Configuration\n\n_NOTE: Logging configuration (e.g., setting of logging levels, formatting) is\nspecific to the underlying logging implementation, and is out of scope for this\nlibrary._\n\n### Selecting a logging implementation\n\nTo control which logging implementation is used, set the `clojure.tools.logging.factory`\nsystem property to the fully-qualified name of a no-arg function that returns an\ninstance of `clojure.tools.logging.impl/LoggerFactory`. There are a number of\nfactory functions provided in the [`clojure.tools.logging.impl`](https://clojure.github.io/tools.logging/#clojure.tools.logging.impl/find-factory)\nnamespace.\n\n[Leiningen example]:\n\n```clojure\n:jvm-opts [\"-Dclojure.tools.logging.factory=clojure.tools.logging.impl/slf4j-factory\"]\n```\n\nIf the system property is unset, an implementation will be automatically chosen\nbased on whichever of the following implementations is successfully loaded first:\n\n1. [SLF4J]\n2. [Apache Commons Logging]\n3. [Log4J 2]\n4. [Log4J]\n5. [java.util.logging]\n\nThe above approach is problematic given that applications often inadvertently pull\nin multiple logging implementations as transitive dependencies. As such, it is\n_strongly_ advised that you set the system property.\n\n### Log4J2\n\nA simple Log4j2 [configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html):\n\n```properties\nstatus = warn\nmonitorInterval = 5\n\nappender.console.type = Console\nappender.console.name = STDOUT\nappender.console.layout.type = PatternLayout\nappender.console.layout.pattern = %date %level %logger %message%n%throwable\n\nrootLogger.level = info\nrootLogger.appenderRef.stdout.ref = STDOUT\n```\n\n*Note:* The above [pattern](https://logging.apache.org/log4j/2.x/manual/layouts.html#Patterns)\nexplicitly uses `%throwable` so that `clojure.lang.ExceptionInfo` exceptions\nwill be printed with their data maps. If either `%xThrowable` (the default) or\n`%rThrowable` is used, the data maps will not be printed.\n\n## FAQ\n\n#### When logging an `ex-info` exception, why isn't the data map printed?\n\nThis is likely because the logging implementation is printing the contents of\n`Throwable.getMessage()`, which returns just the message arg to `ex-info`.\n\nLogging implementations that print the contents of `toString()` or use `Throwable.printStackTrace(...)`\nwill end up printing the data map.\n\n## Thanks\n\n* Chris Dean\n* Phil Hagelberg\n* Richard Newman\n* Sean Corfield\n* Timothy Pratley\n\n## License\n\nCopyright © Rich Hickey, Alex Taggart, and contributors\n\nLicensed under the EPL. (See the file epl.html.)\n\n\n[1.3.0]: https://github.com/clojure/tools.logging/tree/v1.3.0\n[1.2.4]: https://github.com/clojure/tools.logging/tree/v1.2.4\n[Leiningen example]: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#setting-jvm-options\n[SLF4J]: https://www.slf4j.org/\n[Apache Commons Logging]: https://commons.apache.org/logging\n[Log4J 2]: https://logging.apache.org/log4j/2.x/\n[Log4J]: https://logging.apache.org/log4j/1.2/\n[java.util.logging]: https://docs.oracle.com/en/java/javase/13/docs/api/java.logging/java/util/logging/package-summary.html \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojure%2Ftools.logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclojure%2Ftools.logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojure%2Ftools.logging/lists"}