{"id":16696654,"url":"https://github.com/atry/zero-log","last_synced_at":"2026-03-05T12:02:09.696Z","repository":{"id":28597711,"uuid":"32115998","full_name":"Atry/zero-log","owner":"Atry","description":"Automatically exported from code.google.com/p/zero-log","archived":false,"fork":false,"pushed_at":"2017-02-17T09:18:01.000Z","size":212,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T04:22:12.968Z","etag":null,"topics":[],"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/Atry.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-13T01:30:16.000Z","updated_at":"2020-11-02T13:11:40.000Z","dependencies_parsed_at":"2022-08-21T12:10:11.308Z","dependency_job_id":null,"html_url":"https://github.com/Atry/zero-log","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fzero-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fzero-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fzero-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fzero-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atry","download_url":"https://codeload.github.com/Atry/zero-log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248147039,"owners_count":21055463,"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-10-12T17:44:28.519Z","updated_at":"2026-03-05T12:02:09.642Z","avatar_url":"https://github.com/Atry.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"`zero-log` is a logging framework for Scala, which is designed to take advantage of Scala feature to let logging faster and simpler.\r\n\r\n# Why use `zero-log` instead of `log4j`, `logback`, etc... #\r\n  * Zero cost if the log is disabled by compile-time configuration.\r\n  * Zero XML or Propertis files you need to write.\r\n  * 10+ times faster for string formatting than any other Java logging libraries (log4j, logback, ...).\r\n  * Support `@scala.annotation.elidable`.\r\n\r\nFor more comparation, see [log4j VS zero-log](https://github.com/Atry/zero-log/wiki/Log4jVsZeroLog).\r\n\r\n# Performance #\r\n`zero-log` is extremely fast.\r\n\r\nThanks to Scala's `@elidable`, when using compile-time configuration, the cost for disabled logs can be exactly zero.\r\n\r\n`zero-log`'s string formatting can be 10+ times faster than any other Java logging libraries. See [Fastring](https://github.com/Atry/fastring) for more information.\r\n\r\n# Usage #\r\n\r\nYou only need call `ZeroLoggerFactory.newLogger(this)` to get the logger, and call `logger.info()` to log. No more configuation for simple use.\r\n\r\n```\r\npackage com.yourDomain.yourProject\r\nobject Sample {\r\n  implicit val (logger, formatter, appender) = ZeroLoggerFactory.newLogger(this)\r\n\r\n  def main(args: Array[String]) {\r\n    logger.info(\"Logging in a Singleton.\")\r\n    logger.fine(\"Hello,\")\r\n    logger.warning(\"World!\")\r\n    logger.finest(fast\"Faster string formatting: args.length is ${args.length}\")\r\n    new Sample\r\n  }\r\n}\r\n\r\nclass Sample {\r\n  import Sample._\r\n\r\n  logger.info(\"Logging in a class instance.\")\r\n  logger.finer(\"Hello,\")\r\n  logger.severe(\"World!\", new Exception(\"With some Exception\"))\r\n}\r\n```\r\n\r\nNote: By default, only logging level `info`, `warning` and `severe` are enabled, and the other levels are disabled.\r\n\r\n## Configure logging level, formatting, or target ##\r\n\r\nUnlike `log4j`, `logback`, `java.util.logging`, the `zero-log` does not load any XML or Properties file as configuration. Instead, `zero-log` use `ZeroLoggerFactory` to configure logging level, logging formatting, or logging target. If you need custom configuration, just put your own `ZeroLoggerFactory` on scalac's source path.\r\n\r\nFor example, you may create a file at `src/main/scala/zero-log.config.scala` to change logging level for `com.yourDomain.yourProject.Sample`:\r\n\r\n```\r\nimport com.dongxiguo.zeroLog.Filter\r\nimport com.dongxiguo.zeroLog.formatters.SimpleFormatter\r\nimport com.dongxiguo.zeroLog.appenders.ConsoleAppender\r\n\r\n// Set global default logging level to Warning, and send logs to ConsoleAppender\r\nobject ZeroLoggerFactory {\r\n  final def newLogger(singleton: Singleton) =\r\n    (Filter.Warning, SimpleFormatter, ConsoleAppender)\r\n}\r\n\r\npackage com.yourDomain.yourProject {\r\n  object ZeroLoggerFactory {\r\n    // Set package com.yourDomain.yourProject's default logging level to Info\r\n    final def newLogger(singleton: Singleton) =\r\n      (Filter.Info, SimpleFormatter, ConsoleAppender)\r\n\r\n    // Set Sample's logging level to Finest\r\n    final def newLogger(singleton: Sample.type) =\r\n      (Filter.Finest, SimpleFormatter, ConsoleAppender)\r\n  }\r\n}\r\n```\r\n\r\nLook at logger's initializing code in `Sample.scala`:\r\n\r\n```\r\n  implicit val (logger, formatter, appender) = ZeroLoggerFactory.newLogger(this)\r\n```\r\n\r\nWhen `Sample.scala` is compiled with `zero-log.config.scala`, `ZeroLoggerFactory.newLogger` will be resolved as `com.yourDomain.yourProject.ZeroLoggerFactory.newLogger`. So `logger` and `formatter` will be the result of `newLogger` you defined at `zero-log.config.scala`, which are `Filter.Finest` , `SimpleFormatter`, and `ConsoleAppender` for `Sample`.\r\n\r\n### Run-time configuration ###\r\n\r\nWhen you create a library, you may want the user of your library to be able to change logging settings without change your library's source code.\r\n\r\nDon't worry. `zero-log` can resolve `ZeroLoggerFactory` by reflection. Just call `ZeroLoggerFactory.newLogger` without `com.yourDomain.yourProject.ZeroLoggerFactory` in source path, and ship your library without `com.yourDomain.yourProject.ZeroLoggerFactory` in your release. Your users can define their own `com.yourDomain.yourProject.ZeroLoggerFactory` or `com.yourDomain.ZeroLoggerFactory`, which are resoved by `zero-log` at run-time.\r\n\r\n# Downloads #\r\nBinary release and scaladocs can be found on [Maven central repository](http://search.maven.org/#search|ga|1|zero-log). You may download these files directly, or add dependency to `zero-log` in your building management tool's configuration:\r\n\r\n## Sbt ##\r\nIf you use [sbt](http://www.scala-sbt.org/) 0.12.x or 0.13.x,\r\nadd following configuration to your `build.sbt`:\r\n```\r\nlibraryDependencies += \"com.dongxiguo\" %% \"zero-log\" % \"0.3.6\"\r\n```\r\n\r\n## Maven ##\r\nOr add following configuration if you use maven:\r\n```\r\n\u003cproperties\u003e\r\n\t\u003cscala.version\u003e2.11.0\u003c/scala.version\u003e\r\n\u003c/properties\u003e\r\n\u003cdependency\u003e\r\n\t\u003cgroupId\u003ecom.dongxiguo\u003c/groupId\u003e\r\n\t\u003cartifactId\u003ezero-log_2.10\u003c/artifactId\u003e\r\n\t\u003cversion\u003e0.3.6\u003c/version\u003e\r\n\t\u003cscope\u003ecompile\u003c/scope\u003e\r\n\u003c/dependency\u003e\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatry%2Fzero-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatry%2Fzero-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatry%2Fzero-log/lists"}