{"id":28412701,"url":"https://github.com/vbauer/herald","last_synced_at":"2025-06-24T13:31:26.737Z","repository":{"id":27689927,"uuid":"31176447","full_name":"vbauer/herald","owner":"vbauer","description":"Log annotation for logging frameworks","archived":false,"fork":false,"pushed_at":"2022-12-21T21:40:40.000Z","size":672,"stargazers_count":75,"open_issues_count":3,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-03T11:55:05.820Z","etag":null,"topics":["android","guice","java","log4j","logback","logger","logging","logs","slf4j","spring","spring-boot","syslog4j"],"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/vbauer.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-02-22T19:32:22.000Z","updated_at":"2025-02-23T06:49:18.000Z","dependencies_parsed_at":"2023-01-14T07:17:35.888Z","dependency_job_id":null,"html_url":"https://github.com/vbauer/herald","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/vbauer/herald","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbauer%2Fherald","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbauer%2Fherald/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbauer%2Fherald/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbauer%2Fherald/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vbauer","download_url":"https://codeload.github.com/vbauer/herald/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbauer%2Fherald/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261685465,"owners_count":23194109,"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":["android","guice","java","log4j","logback","logger","logging","logs","slf4j","spring","spring-boot","syslog4j"],"created_at":"2025-06-02T23:44:45.730Z","updated_at":"2025-06-24T13:31:26.725Z","avatar_url":"https://github.com/vbauer.png","language":"Java","readme":"\n# Herald\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Herald-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2042)\n[![Build Status](https://travis-ci.org/vbauer/herald.svg)](https://travis-ci.org/vbauer/herald)\n[![Coverage Status](https://coveralls.io/repos/vbauer/herald/badge.svg?branch=master)](https://coveralls.io/r/vbauer/herald?branch=master)\n[![Maven](https://img.shields.io/github/tag/vbauer/herald.svg?label=maven)](https://jitpack.io/#vbauer/herald)\n[![Codacy Badge](https://api.codacy.com/project/badge/grade/10aa5200922f4850a3ea21e8fe81ecd9)](https://www.codacy.com/app/bauer-vlad/herald)\n\n\u003cimg align=\"right\" style=\"margin-left: 15px\" width=\"280\" height=\"400\" src=\"misc/white-rabbit.png\"\u003e\n\n\u003e \"Why, sometimes I've believed as many as six impossible things before breakfast.\" - Lewis Carroll, Alice in Wonderland.\n\n**Herald** provides a very simple way to initialize logger objects and does all magic for you.\nYou can annotate any field of some class with a `@Log` annotation to let Herald inject suitable logger in this field. \nIt does not matter whether it is a static field or not.\n\nJust forget about this code:\n```java\nprivate static final Logger LOGGER =\n    LoggerFactory.getLogger(Foo.class);\n```\n\nWrite less code, use short form:\n```java\n@Log\nprivate Logger logger;\n```\n\n**Online documentation:**\n\n* [Maven site](https://vbauer.github.io/herald)\n* [Javadoc](https://vbauer.github.io/herald/apidocs)\n\n\n## Main features\n\n* Ready-To-Use solution\n* Small library size with zero dependencies\n* Compact and very simple API\n* Compatible with:\n    * Pure Java SE\n    * [Spring Framework](https://spring.io)\n        * [Spring Boot](http://projects.spring.io/spring-boot/)\n    * [Guice](https://github.com/google/guice)\n    * [RoboGuice](https://github.com/roboguice/roboguice)\n    * [Android Platform](http://developer.android.com)\n\n\n## Supported logging frameworks\n\n* [JavaTM 2 platform's core logging framework](http://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html)\n* [Apache Commons Logging](http://commons.apache.org/proper/commons-logging)\n* [Simple Logging Facade for Java (SLF4J)](http://www.slf4j.org)\n* [SLF4J Extended logger](http://www.slf4j.org/extensions.html#extended_logger)\n* [Logback](http://logback.qos.ch)\n* [Apache Log4j](https://logging.apache.org/log4j/1.2/)\n* [Apache Log4j 2](http://logging.apache.org/log4j/2.x/)\n* [JBoss Logging](http://docs.jboss.org/jbosslogging/latest/org/jboss/logging/Logger.html)\n* [Syslog4j](http://syslog4j.org)\n* [Syslog4j fork](https://github.com/Graylog2/syslog4j-graylog2) from [Graylog](https://www.graylog.org)\n* [Fluent Logger for Java](https://github.com/fluent/fluent-logger-java)\n* [Play Framework Logging API](https://www.playframework.com/documentation/2.4.x/JavaLogging)\n\nIt is also possible to add other logging frameworks:\n\n* Create new class in your project, it should implement interface `com.github.vbauer.herald.logger.LogFactory`.\n  Add all necessary logic about logger creation in this class.\n* Create `ServiceLoader`'s file in your project: \"META-INF/services/com.github.vbauer.herald.logger.LogFactory\".\n* Add full class name of your new extension in this file.\n\nThat's all!\n\n\n## Setup\n\nMaven:\n```xml\n\u003crepository\u003e\n    \u003cid\u003ejitpack.io\u003c/id\u003e\n    \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n\u003c/repository\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.vbauer\u003c/groupId\u003e\n    \u003cartifactId\u003eherald\u003c/artifactId\u003e\n    \u003cversion\u003e1.2.3\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nGradle:\n```groovy\nrepositories {\n    maven {\n        url \"https://jitpack.io\"\n    }\n}\n\ndependencies {\n    compile 'com.github.vbauer:herald:1.2.3'\n}\n```\n\n## Configuration\n\n### Java configuration\n\nThe project is integrated with Spring \u0026 Guice frameworks, but can be used without it:\n```java\nLoggerInjector.inject(bean);\n\n// or even using varargs:\nLoggerInjector.inject(bean1, bean2, bean3);\n```\n\nAs you can see, it is unnecessary to do some specific configuration when you use it in Java without IOC container.  \n\n### Android configuration\n\nYou need to create base class for your component (ex: Activity) and call `LoggerInjector.inject`:\n\n```java\npublic class BaseActivity extends Activity {\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        LoggerInjector.inject(this);\n    }\n}\n```\n\n### Guice / RoboGuice configuration\n\n**Herald** contains specific Guice module to support `@Log` annotation (`com.github.vbauer.herald.ext.guice.LogModule`):\n\n```java\nfinal Injector injector = Guice.createInjector(new LogModule());\n```\n\nNow, all your beans will be processed with LoggerInjector and logger fields will be initialized if necessary.\n\n### Spring configuration\n\n#### Java based configuration\n\nYou need to configure only one `BeanPostProcessor`:\n\n```java\n@Configuration\npublic class AppContext {\n\n    @Bean\n    public LogBeanPostProcessor logBeanPostProcessor() {\n        return new LogBeanPostProcessor();\n    }\n\n}\n```\n\n#### XML Schema-based configuration\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cbeans xmlns=\"http://www.springframework.org/schema/beans\"\n    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n    xsi:schemaLocation=\"\n        http://www.springframework.org/schema/beans\n        http://www.springframework.org/schema/beans/spring-beans.xsd\"\u003e\n\n    \u003cbean class=\"com.github.vbauer.herald.ext.spring.LogBeanPostProcessor\" /\u003e\n\n\u003c/beans\u003e\n```\n\n#### Spring Boot support\n\nHerald has out of the box integration with Spring Boot. You do not need to define `LogBeanPostProcessor` in your application context.\nSpring Boot [auto-configuration](https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-auto-configuration.html) attempts to automatically configure your Spring application based on the jar dependencies that you have added.\n\nSee [LogAutoConfiguration](src/main/java/com/github/vbauer/herald/ext/spring/LogAutoConfiguration.java) for more details.\n\n\n## @Log annotation\n\nYou can use `@Log` annotation in 2 ways:\n\n* Put it on class - All suitable logger fields will be injected. Validation check will be switched off, so all undefined logger fields will be skipped.\n* Put it on field - It allows you to inject only suitable logger and throws `MissedLogFactoryException` otherwise.\n\nIt is also possible to configure logger name using this annotation:\n\n```java\n@Log(\"MyCustomLoggerName\")\nprivate Logger logger;\n```\n\nIf you do not specify it, then class name will be used as logger name.\n\nIf you want to specify mandatory for logger instantiation, use `required` parameter (default is `true`).\nUse `@Log(required = false)` to make your logger object optional (it could be useful in some rare cases).\n\n\n## FAQ\n\n* **Q:** How to select protocol for Syslog4j?\n    * **A:** Use @Log.name(), default protocol is \"udp\".\n* **Q:** How to configure Syslog4j with Herald?\n    * **A:** Use standard Syslog4j API, ex:\n    ```java\n    final SyslogIF syslog = Syslog.getInstance(\"udp\");\n    syslog.getConfig().setHost(\"192.168.100.1\");\n    syslog.getConfig().setPort(1514);\n    ```\n\n\n## Development\n\nTo build project in strict mode with tests, you can run:\n\n```bash\nmvn -P strict clean package\n```\n\n\n## Might also like\n\n* [jconditions](https://github.com/vbauer/jconditions) - Extra conditional annotations for JUnit.\n* [jackdaw](https://github.com/vbauer/jackdaw) - Java Annotation Processor which allows to simplify development.\n* [houdini](https://github.com/vbauer/houdini) - Type conversion system for Java projects.\n* [caesar](https://github.com/vbauer/caesar) - Library that allows to create async beans from sync beans.\n* [commons-vfs2-cifs](https://github.com/vbauer/commons-vfs2-cifs) - SMB/CIFS provider for Commons VFS.\n* [avconv4java](https://github.com/vbauer/avconv4java) - Java interface to avconv tool.\n\n\n## License\n\nCopyright 2015 Vladislav Bauer\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    http://www.apache.org/licenses/LICENSE-2.0\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\nSee [LICENSE](LICENSE) file for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbauer%2Fherald","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvbauer%2Fherald","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbauer%2Fherald/lists"}