{"id":13640649,"url":"https://github.com/mlangc/slf4zio","last_synced_at":"2026-01-14T03:24:45.948Z","repository":{"id":46237025,"uuid":"193558255","full_name":"mlangc/slf4zio","owner":"mlangc","description":"Simple convenience layer on top of SLF4J for ZIO","archived":false,"fork":false,"pushed_at":"2022-09-11T14:13:21.000Z","size":129,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-02T02:40:05.058Z","etag":null,"topics":["scala","slf4j","zio"],"latest_commit_sha":null,"homepage":null,"language":"Scala","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/mlangc.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":"2019-06-24T18:28:05.000Z","updated_at":"2022-10-15T09:50:20.000Z","dependencies_parsed_at":"2022-09-13T14:22:47.752Z","dependency_job_id":null,"html_url":"https://github.com/mlangc/slf4zio","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/mlangc/slf4zio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlangc%2Fslf4zio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlangc%2Fslf4zio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlangc%2Fslf4zio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlangc%2Fslf4zio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlangc","download_url":"https://codeload.github.com/mlangc/slf4zio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlangc%2Fslf4zio/sbom","scorecard":{"id":653151,"data":{"date":"2025-08-11","repo":{"name":"github.com/mlangc/slf4zio","commit":"7eff220e755504492fcd07342d03bc042f2a20f9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":1,"reason":"Found 4/23 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'","Warn: branch protection not enabled for branch '0.5.0'","Warn: branch protection not enabled for branch '0.3.0'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T13:59:48.083Z","repository_id":46237025,"created_at":"2025-08-21T13:59:48.083Z","updated_at":"2025-08-21T13:59:48.083Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"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":["scala","slf4j","zio"],"created_at":"2024-08-02T01:01:13.101Z","updated_at":"2026-01-14T03:24:45.934Z","avatar_url":"https://github.com/mlangc.png","language":"Scala","funding_links":[],"categories":["Logging"],"sub_categories":[],"readme":"# SLF4ZIO\n*Integrates SLF4J with ZIO in a simple manner.*\n\n[![Latest Release](https://img.shields.io/maven-central/v/com.github.mlangc/slf4zio_2.13?color=green\u0026label=latest-release)](https://oss.sonatype.org/content/repositories/releases/com/github/mlangc/slf4zio_2.13)\n[![Latest Snapshot](https://img.shields.io/nexus/s/com.github.mlangc/slf4zio_2.13?label=latest-snapshot\u0026server=https%3A%2F%2Foss.sonatype.org)](https://oss.sonatype.org/content/repositories/snapshots/com/github/mlangc/slf4zio_2.13/)\n\n## When to Use\nIf your code is based on [ZIO](https://zio.dev/) and you want to log with [SLF4J](https://www.slf4j.org/) without additional abstractions getting\nin your way.\n\n## How to Use\nThe library supports three different coding styles, that you can mix and match according to your needs. They are listed here in the order of\nmy personal preference:\n\n### 1. Using the LoggingSupport Convenience Trait\n\n````scala\nimport com.github.mlangc.slf4zio.api._\nimport zio._\n\nobject SomeObject extends LoggingSupport {\n  def doStuff: Task[Unit] = {\n    for {\n      _ \u003c- logger.warnIO(\"What the heck\")\n      _ \u003c- ZIO.ifZIO(Random.nextBoolean)(\n        logger.infoIO(\"Uff, that was close\"),\n        logger.errorIO(\"Game over\", new IllegalStateException(\"This is the end\"))\n      )\n\n      _ \u003c- ZIO.attempt {\n        // logger is just a plain SLF4J logger; you can therefore use it from\n        // effectful code directly:\n        logger.trace(\"Wink wink nudge nudge\")\n      }\n\n      _ \u003c- ZIO\n        .sleep(8.millis)\n        .as(23)\n        .perfLog(\n          // See below for more examples with `LogSpec`\n          LogSpec\n            .onSucceed[Int]((d, i) =\u003e debug\"Finally done with $i after ${d.render}\")\n            .withThreshold(5.millis)\n        )\n    } yield ()\n  }\n}\n````\n\n#### Side Note\nNote that the `logger` field in the `LoggingSupport` trait is lazy. Since the implicit class\nthat implements the various `**IO` methods, like `debugIO`, `infoIO` and so forth, wraps the\nlogger using a [by-name parameter](https://docs.scala-lang.org/tour/by-name-parameters.html),\nlogger initialization won't happen before `unsafeRun`, if you don't access the logger directly\nfrom non effectful code. To ensure referential transparency for creating an object of a class that\ninherits the `LoggingSupport` trait even with outright broken or strange logger implementations,\nyou have wrap the creation of the object in an effect of its own. It might make more sense to use\nanother logger implementation though. For practical purposes, I would consider obtaining a \nlogger to be a pure operation as soon as the logging framework has finished its initialization,\nand not care too much about this subtlety.\n\n### 2. Creating Loggers as Needed\n\n```scala\nimport com.github.mlangc.slf4zio.api._\nimport zio._\n\nval effect: Task[Unit] = {\n  // ...\n  class SomeClass\n  // ...\n  for {\n    logger \u003c- makeLogger[SomeClass]\n    _ \u003c- logger.debugIO(\"Debug me tender\")\n    // ...\n    _ \u003c- ZIO.attempt {\n      // Note that makeLogger just returns a plain SLF4J logger; you can therefore use it from\n      // effectful code directly:\n      logger.info(\"Don't be shy\")\n      // ...\n      logger.warn(\"Please take me home\")\n      // ...\n    }\n    // ...\n    _ \u003c- logger.perfLogZIO(ZIO.sleep(10.millis))(\n      // See below for more examples with `LogSpec`\n      LogSpec.onSucceed(d =\u003e info\"Feeling relaxed after sleeping ${d.render}\")\n    )\n  } yield ()\n}\n```\n\n### 3. Using the Logging Service\n\n```scala\nimport com.github.mlangc.slf4zio.api._\nimport zio._\n\nval effect: RIO[Logging, Unit] =\n  for {\n    _ \u003c- logging.warnIO(\"Surprise, surprise\")\n    plainLogger \u003c- logging.logger\n    _ \u003c- ZIO.attempt {\n      plainLogger.debug(\"Shhh...\")\n      plainLogger.warn(\"The devil always comes in disguise\")\n    }\n    _ \u003c- logging.traceIO(\"...\")\n    getNumber = ZIO.succeed(42)\n    // See below for more examples with `LogSpec`\n    _ \u003c- getNumber.perfLogZ(LogSpec.onSucceed(d =\u003e debug\"Got number after ${d.render}\"))\n  } yield ()\n```      \n\n### Using Markers\n\n```scala\nimport com.github.mlangc.slf4zio.api._\nimport zio._\n\nval effect: RIO[Logging, Unit] =\n  for {\n    marker \u003c- getMarker(\"[MARKER]\")\n    _ \u003c- logging.infoIO(marker, \"Here we are\")\n    logger \u003c- logging.logger\n    _ \u003c- logger.debugIO(marker, \"Wat?\")\n    _ \u003c- ZIO.attempt {\n      logger.warn(marker, \"Don't worry\")\n    }\n  } yield ()\n```    \n\n### Performance Logging\nApart from providing ZIO aware wrappers for [SLF4J](https://www.slf4j.org/), the library might also\nhelp you with performance related logging. The examples from above are meant to give you the overall\nidea. Here is another snippet, that is meant to illustrate how to build complex `LogSpec`s from simple\nones, utilizing the underlying monoidial structure:\n\n```scala\nimport com.github.mlangc.slf4zio.api._\nimport zio._\n\n// Simple specs can be combined using the `++` to obtain more complex specs\nval logSpec1: LogSpec[Throwable, Int] =\n  LogSpec.onSucceed[Int]((d, a) =\u003e info\"Succeeded after ${d.render} with $a\") ++\n    LogSpec.onError[Throwable]((d, th) =\u003e error\"Failed after ${d.render} with $th\") ++\n    LogSpec.onTermination((d, c) =\u003e error\"Fatal failure after ${d.render}: ${c.prettyPrint}\")\n\n// A threshold can be applied to a LogSpec. Nothing will be logged, unless the threshold is exceeded.\nval logSpec2: LogSpec[Any, Any] =\n  LogSpec\n    .onSucceed(d =\u003e warn\"Operation took ${d.render}\")\n    .withThreshold(1.milli)\n\n// Will behave like logSpec1 and eventually log a warning as specified in logSpec2\nval logSpec3: LogSpec[Throwable, Int] = logSpec1 ++ logSpec2\n\nval effect: ZIO[Logging, Nothing, Unit] = for {\n  _ \u003c- ZIO.sleep(5.micros).perfLogZ(LogSpec.onSucceed(d =\u003e debug\"Done after ${d.render}\"))\n  _ \u003c- ZIO.sleep(1.milli).as(42).perfLogZ(logSpec1)\n  _ \u003c- ZIO.sleep(2.milli).perfLogZ(logSpec2)\n  _ \u003c- ZIO.sleep(3.milli).as(23).perfLogZ(logSpec3)\n} yield ()\n```     \n\n### Using MDC convenience APIs\nSLF4ZIO also ships with a set of convenience APIs for `org.slf4j.MDC`. Note however, that traditional\nMDC implementations are based on thread local data, which doesn't work at all with ZIO, where a\nsingle `zio.Fiber` might run on different threads during its lifetime, and a single thread might \naccommodate multiple fibers. **If you want to use MDC logging in your ZIO based application, it is\ncritical to use a fiber aware MDC implementation, as provided for example by \n[zio-interop-log4j2](https://github.com/mlangc/zio-interop-log4j2). `MDZIO` is just a collection of\nconvenience APIs for interacting with `org.slf4j.MDC` that doesn't add any functionality of its own.**\n\n## Alternatives\nIf you want to track logging effects using the [ZIO Environment](http://degoes.net/articles/zio-environment) exclusively, consider using\n[zio-logging](https://github.com/zio/zio-logging). If you are into Tagless Final,\ntake a look at [log4cats](https://github.com/ChristopherDavenport/log4cats).\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlangc%2Fslf4zio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlangc%2Fslf4zio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlangc%2Fslf4zio/lists"}