{"id":15370156,"url":"https://github.com/jsalinaspolo/logcapture","last_synced_at":"2026-01-11T17:48:47.582Z","repository":{"id":37899533,"uuid":"82174850","full_name":"jsalinaspolo/logcapture","owner":"jsalinaspolo","description":"A testing library for asserting logging messages","archived":false,"fork":false,"pushed_at":"2025-04-07T09:17:50.000Z","size":534,"stargazers_count":22,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-07T09:25:00.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsalinaspolo.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-16T11:45:09.000Z","updated_at":"2025-04-07T09:08:49.000Z","dependencies_parsed_at":"2024-10-16T11:01:18.770Z","dependency_job_id":"680706e1-06a1-415a-a0c9-03a9f5d70563","html_url":"https://github.com/jsalinaspolo/logcapture","commit_stats":{"total_commits":207,"total_committers":14,"mean_commits":"14.785714285714286","dds":0.7149758454106281,"last_synced_commit":"bff065a14053ad0aa165bbfa55dbe8db18730a2c"},"previous_names":["mustaine/logcapture"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsalinaspolo%2Flogcapture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsalinaspolo%2Flogcapture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsalinaspolo%2Flogcapture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsalinaspolo%2Flogcapture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsalinaspolo","download_url":"https://codeload.github.com/jsalinaspolo/logcapture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248736098,"owners_count":21153533,"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-01T13:40:08.729Z","updated_at":"2026-01-11T17:48:47.575Z","avatar_url":"https://github.com/jsalinaspolo.png","language":"Java","funding_links":[],"categories":["测试"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/jsalinaspolo/logcapture.svg?branch=master)](https://travis-ci.org/jsalinaspolo/logcapture)\n[![Sonatype Nexus](https://img.shields.io/nexus/r/org.logcapture/logcapture-core?server=https%3A%2F%2Fs01.oss.sonatype.org)](https://repo1.maven.org/maven2/org/logcapture/)\n[![codecov](https://codecov.io/gh/jsalinaspolo/logcapture/branch/master/graph/badge.svg)](https://codecov.io/gh/jsalinaspolo/logcapture)\n[![Known Vulnerabilities](https://snyk.io/test/github/jsalinaspolo/logcapture/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/jsalinaspolo/logcapture?targetFile=build.gradle)\n\n# LogCapture\n\nLogCapture is a testing library for asserting logging messages.\n\n\u003e :warning: Latest release with Java 1.8 and/or spock 1.0 support is `1.3.4` \n## How it works\n\n\nUsing JUnit Rule:\n\n```java\n@Rule\npublic LogCaptureRule logCaptureRule = new LogCaptureRule();\n\n@Test\npublic void verify_logs_using_rule() {\n  log.info(\"a message\");\n\n  logCaptureRule.logged(aLog().info().withMessage(\"a message\"));\n}\n```\n\nUsing JUnit 5 Extension:\n\n```java\n@RegisterExtension\npublic LogCaptureExtension logCaptureExtension = new LogCaptureExtension();\n\n@Test\npublic void verify_logs_using_extension() {\n  log.info(\"a message\");\n\n  logCaptureExtension.logged(aLog().info().withMessage(\"a message\"));\n}\n```\n\nUsing Spock:\n\n```groovy\nclass LogCaptureSpecShould extends LogCaptureSpec {\n\n  @Shared log = LoggerFactory.getLogger(getClass())\n\n  def \"verify log message\"() {\n    expect:\n    log.info(\"a message\");\n\n    logged(aLog().info().withMessage(\"a message\"))\n  }\n}\n```\n\nUsing Kotest:\n\n```kotlin\nclass LogCaptureListenerSpec : StringSpec({\n  val logCaptureListener = LogCaptureListener()\n  listener(logCaptureListener)  // Add LogCaptureListener\n\n  val log: Logger = LoggerFactory.getLogger(LogCaptureListenerSpec::class.java)\n\n  \"verify log messages\" {\n    log.info(\"a message\")\n\n    logCaptureListener.logged(aLog().info().withMessage(\"a message\"))\n  }\n})\n```\n\nUsing Kotest v6:\n\n```kotlin\nclass LogCaptureListenerSpec : StringSpec({\n  val logCaptureListener = LogCaptureListener()\n  extensions(logCaptureListener)  // Add LogCaptureListener\n\n  val log: Logger = LoggerFactory.getLogger(LogCaptureListenerSpec::class.java)\n\n  \"verify log messages\" {\n    log.info(\"a message\")\n\n    logCaptureListener.logged(aLog().info().withMessage(\"a message\"))\n  }\n})\n```\n\nMore example how to use the library at [ExampleShould.java](https://github.com/jsalinaspolo/logcapture/blob/main/logcapture-example/src/test/java/org/logcapture/example/ExampleShould.java)\n\n## Binaries\n\nBinaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.logcapture).\n\nGradle\n\n```\ntestImplementation 'org.logcapture:logcapture-core:x.y.z'\n```\n\nadd one of the test library dependency \n\n```\ntestImplementation 'org.logcapture:logcapture-junit4:x.y.z'\ntestImplementation 'org.logcapture:logcapture-junit5:x.y.z'\ntestImplementation 'org.logcapture:logcapture-spock2:x.y.z'\ntestImplementation 'org.logcapture:logcapture-kotest:x.y.z'\ntestImplementation 'org.logcapture:logcapture-kotest6:x.y.z'\n```\n\n\nMaven:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.logcapture\u003c/groupId\u003e\n    \u003cartifactId\u003elogcapture-core\u003c/artifactId\u003e\n    \u003cversion\u003ex.y.z\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\n## Why LogCapture?\n\nLogging should be a **first class citizen** in every system that aims to be easily diagnosed and maintained. Logging/testing first could help \nyou to drive production code. At the same time it is easy to log object references and objects that includes private information like passwords or tokens \nand not realising until we actually read production logs.\n\nWe should test how robust are our non-functional capabilities, and not only our functional features. Being able to diagnose, \nand ultimately fix, issues is a non-functional dimension that should be subject to the same standards as performance, reliability or security.\n\nLogging first development could give you the following benefits:\n\n* Help you to come up with some useful logging that makes sense in context, that exposes enough, and just enough, semantic \ninformation and that does not leak secure information.\n* Help you to understand beforehand what are the high level technical details that your design will implement.\n* Provide insights to security, support or operations engineers that could have different needs and drivers that application developers.\n* Help you to come up with rules for your logging monitoring system.\n\n## License\n\nThis project is licensed under [MIT license](http://opensource.org/licenses/MIT).\n\n## Contributing\n\nGithub is for social coding: if you want to write code, I encourage contributions through pull requests from forks of this repository. \nCreate Github tickets for bugs and new features and comment on the ones that you are interested in.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsalinaspolo%2Flogcapture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsalinaspolo%2Flogcapture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsalinaspolo%2Flogcapture/lists"}