{"id":16911864,"url":"https://github.com/vitalijr2/mock-jdk-platform-logging","last_synced_at":"2025-12-18T08:30:17.719Z","repository":{"id":248558651,"uuid":"829016862","full_name":"vitalijr2/mock-jdk-platform-logging","owner":"vitalijr2","description":"JDK Platform Logging Service with mock loggers backed by Mockito.","archived":false,"fork":false,"pushed_at":"2024-09-04T19:30:56.000Z","size":99,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-06T03:36:36.090Z","etag":null,"topics":["java-logging","jdk-logging","junit-extension","logger-mock","logging-library","mock-library","mocks"],"latest_commit_sha":null,"homepage":"","language":"Java","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/vitalijr2.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},"funding":{"custom":["https://buymeacoffee.com/vitalij_r2","https://send.monobank.ua/jar/9r5bd6ejUC?f=enabled\u0026t=mock-jdk-platform-logging","https://next.privat24.ua/send/cblin","https://mobile-app.pumb.ua/NaHVnD3xDZh1mscq7"],"ko_fi":"vitalij_r2","liberapay":"vitalij_r2"}},"created_at":"2024-07-15T15:29:24.000Z","updated_at":"2024-08-20T16:02:32.000Z","dependencies_parsed_at":"2024-08-21T20:49:04.817Z","dependency_job_id":null,"html_url":"https://github.com/vitalijr2/mock-jdk-platform-logging","commit_stats":null,"previous_names":["vitalijr2/mock-jdk-platform-logging"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalijr2%2Fmock-jdk-platform-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalijr2%2Fmock-jdk-platform-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalijr2%2Fmock-jdk-platform-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalijr2%2Fmock-jdk-platform-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitalijr2","download_url":"https://codeload.github.com/vitalijr2/mock-jdk-platform-logging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219851386,"owners_count":16556245,"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":["java-logging","jdk-logging","junit-extension","logger-mock","logging-library","mock-library","mocks"],"created_at":"2024-10-13T19:07:51.401Z","updated_at":"2025-12-18T08:30:17.676Z","avatar_url":"https://github.com/vitalijr2.png","language":"Java","funding_links":["https://buymeacoffee.com/vitalij_r2","https://send.monobank.ua/jar/9r5bd6ejUC?f=enabled\u0026t=mock-jdk-platform-logging","https://next.privat24.ua/send/cblin","https://mobile-app.pumb.ua/NaHVnD3xDZh1mscq7","https://ko-fi.com/vitalij_r2","https://liberapay.com/vitalij_r2"],"categories":[],"sub_categories":[],"readme":"# Mock of JDK Platform Logging\n\nJDK Platform Logging Service with mock loggers backed by [Mockito][].\n\n\u003e [!IMPORTANT]\n\u003e Please use [mock-loggers-jdk-platform-logging][mock-loggers] instead.\n\n[![Java Version][java-version]][jdk-download]\n![jUnit Version][junit-version]\n![Mockito Version][mockito-version]\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html)  \n![Maven Central Last Update][maven-central-last-update]\n[![Maven Central][maven-central]][maven-central-link]\n[![Javadoc][javadoc]][javadoc-link]  \n\n## How to use\n\nJust put a test dependency to your POM:\n```xml\n\u003cdependency\u003e\n    \u003cartifactId\u003emock-jdk-platform-logging\u003c/artifactId\u003e\n    \u003cgroupId\u003eio.github.vitalijr2.logging\u003c/groupId\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n    \u003cversion\u003e1.1.3\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nThe most basic usage example looks like this:\n```java\n@Test\nvoid helloWorld() {\n    var helloService = new HelloService();\n\n    assertDoesNotThrow(helloService::sayHelloWorld);\n\n    verify(System.getLogger(\"HelloService\")).log(Level.INFO, \"Hello World!\");\n}\n```\nSee more details at [HelloServiceBasicTest.java](src/it/hello-world/src/test/java/example/hello/HelloServiceBasicTest.java)\n\nIt should be taken into account that all loggers are initialized only once during the run of tests.\nTherefore, a more complex example cleans the loggers before (or after) each test:\n```java\n// the static logger instance\nprivate static Logger logger;\n\n// initialize the mock logger once\n@BeforeAll\nstatic void setUpClass() {\n    logger = System.getLogger(\"HelloService\");\n}\n\n// clean the mock logger after each test\n@AfterEach\nvoid tearDown() {\n    clearInvocations(logger);\n}\n\n// use the mock logger in a test\n@DisplayName(\"Names\")\n@ParameterizedTest(name = \"\u003c{0}\u003e\")\n@ValueSource(strings = {\"John\", \"Jane\"})\nvoid names(String name) {\n    var helloService = new HelloService();\n\n    assertDoesNotThrow(() -\u003e helloService.sayHello(name));\n\n    var logger = System.getLogger(\"HelloService\");\n\n    verify(logger).log(Level.INFO, \"Hello \" + name + \"!\");\n    verifyNoMoreInteractions(logger);\n}\n```\nSee more details at [HelloServiceFullTest.java](src/it/hello-world/src/test/java/example/hello/HelloServiceFullTest.java)\n\nSince the version **1.1.0** you can use the jUnit extension for automation.\n```java\n@ExtendWith(MockLoggerExtension.class)\nclass HelloServiceExtensionTest {\n\n    private static Logger logger;\n\n    @BeforeAll\n    static void setUpClass() {\n        logger = System.getLogger(\"HelloService\");\n    }\n\n    @DisplayName(\"Names\")\n    @ParameterizedTest(name = \"\u003c{0}\u003e\")\n    @ValueSource(strings = {\"John\", \"Jane\"})\n    void names(String name) {\n        var helloService = new HelloService();\n\n        assertDoesNotThrow(() -\u003e helloService.sayHello(name));\n\n        var logger = System.getLogger(\"HelloService\");\n\n        verify(logger).log(Level.INFO, \"Hello \" + name + \"!\");\n        verifyNoMoreInteractions(logger);\n    }\n\n}\n```\nSee more details at [HelloServiceExtensionTest.java](src/it/hello-world/src/test/java/example/hello/HelloServiceExtensionTest.java)\n\nSince the version **1.1.3** you can use the annotation for automation.\n```java\n@MockLoggers\nclass HelloServiceAnnotationTest {\n\n    private static Logger logger;\n\n    @BeforeAll\n    static void setUpClass() {\n        logger = System.getLogger(\"HelloService\");\n    }\n\n    @DisplayName(\"Names\")\n    @ParameterizedTest(name = \"\u003c{0}\u003e\")\n    @ValueSource(strings = {\"John\", \"Jane\"})\n    void names(String name) {\n        var helloService = new HelloService();\n\n        assertDoesNotThrow(() -\u003e helloService.sayHello(name));\n\n        var logger = System.getLogger(\"HelloService\");\n\n        verify(logger).log(Level.INFO, \"Hello \" + name + \"!\");\n        verifyNoMoreInteractions(logger);\n    }\n\n}\n```\nSee more details at [HelloServiceAnnotationTest.java](src/it/hello-world/src/test/java/example/hello/HelloServiceAnnotationTest.java)\n\n## Credits\n\nThere are two projects which inspired me to make this library:\n\n- [s4u/slf4j-mock][slf4j-mock]\n- [ocarlsen/mock-slf4j-impl][mock-slf4j-impl]\n\n## Contributing\n\nPlease read [Contributing](contributing.md).\n\n## History\n\nSee [Changelog](changelog.md)\n\n## License\n\nCopyright 2024 Vitalij Berdinskih\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n\u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n[Apache License v2.0](LICENSE)  \n\n[Mockito]: https://site.mockito.org\n\n[maven-central-last-update]: https://img.shields.io/maven-central/last-update/io.github.vitalijr2.logging/mock-jdk-platform-logging\n\n[maven-central]: https://img.shields.io/maven-central/v/io.github.vitalijr2.logging/mock-jdk-platform-logging\n\n[maven-central-link]: https://central.sonatype.com/artifact/io.github.vitalijr2.logging/mock-jdk-platform-logging?smo=true\n\n[javadoc]: https://javadoc.io/badge2/io.github.vitalijr2.logging/mock-jdk-platform-logging/javadoc.svg\n\n[javadoc-link]: https://javadoc.io/doc/io.github.vitalijr2.logging/mock-jdk-platform-logging\n\n[java-version]: https://img.shields.io/static/v1?label=Java\u0026message=11\u0026color=blue\u0026logoColor=E23D28\n\n[jdk-download]: https://www.oracle.com/java/technologies/downloads/#java11\n\n[junit-version]: https://img.shields.io/static/v1?label=jUnit\u0026message=5.11.3\u0026color=blue\u0026logo=junit5\u0026logoColor=E23D28\n\n[mockito-version]: https://img.shields.io/static/v1?label=Mockito\u0026message=5.14.2\u0026color=blue\u0026logoColor=E23D28\n\n[slf4j-mock]: https://github.com/s4u/slf4j-mock\n\n[mock-slf4j-impl]: https://github.com/ocarlsen/mock-slf4j-impl\n\n[mock-loggers]: https://github.com/vitalijr2/mock-loggers","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalijr2%2Fmock-jdk-platform-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitalijr2%2Fmock-jdk-platform-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalijr2%2Fmock-jdk-platform-logging/lists"}