Herald provides a very simple way to initialize logger objects and does all magic for you. You can annotate any field of some class with a @Log annotation to let Herald inject suitable logger in this field. It does not matter whether it is a static field or not.

Programming language: Java
License: Apache License 2.0
Tags: Logging     Java     Log Service     Spring     Spring Boot     Guice    
Latest version: v1.2.3

Herald alternatives and similar libraries

Based on the "Logging" category.
Alternatively, view Herald alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Herald or a related project?

Add another 'Logging' Library



Android Arsenal Build Status Coverage Status Maven Codacy Badge

"Why, sometimes I've believed as many as six impossible things before breakfast." - Lewis Carroll, Alice in Wonderland.

Herald provides a very simple way to initialize logger objects and does all magic for you. You can annotate any field of some class with a @Log annotation to let Herald inject suitable logger in this field. It does not matter whether it is a static field or not.

Just forget about this code:

private static final Logger LOGGER =

Write less code, use short form:

private Logger logger;

Online documentation:

Main features

Supported logging frameworks

It is also possible to add other logging frameworks:

  • Create new class in your project, it should implement interface com.github.vbauer.herald.logger.LogFactory. Add all necessary logic about logger creation in this class.
  • Create ServiceLoader's file in your project: "META-INF/services/com.github.vbauer.herald.logger.LogFactory".
  • Add full class name of your new extension in this file.

That's all!






repositories {
    maven {
        url "https://jitpack.io"

dependencies {
    compile 'com.github.vbauer:herald:1.2.3'


Java configuration

The project is integrated with Spring & Guice frameworks, but can be used without it:


// or even using varargs:
LoggerInjector.inject(bean1, bean2, bean3);

As you can see, it is unnecessary to do some specific configuration when you use it in Java without IOC container.

Android configuration

You need to create base class for your component (ex: Activity) and call LoggerInjector.inject:

public class BaseActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {

Guice / RoboGuice configuration

Herald contains specific Guice module to support @Log annotation (com.github.vbauer.herald.ext.guice.LogModule):

final Injector injector = Guice.createInjector(new LogModule());

Now, all your beans will be processed with LoggerInjector and logger fields will be initialized if necessary.

Spring configuration

Java based configuration

You need to configure only one BeanPostProcessor:

public class AppContext {

    public LogBeanPostProcessor logBeanPostProcessor() {
        return new LogBeanPostProcessor();

XML Schema-based configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"

    <bean class="com.github.vbauer.herald.ext.spring.LogBeanPostProcessor" />

Spring Boot support

Herald has out of the box integration with Spring Boot. You do not need to define LogBeanPostProcessor in your application context. Spring Boot auto-configuration attempts to automatically configure your Spring application based on the jar dependencies that you have added.

See [LogAutoConfiguration](src/main/java/com/github/vbauer/herald/ext/spring/LogAutoConfiguration.java) for more details.

@Log annotation

You can use @Log annotation in 2 ways:

  • 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.
  • Put it on field - It allows you to inject only suitable logger and throws MissedLogFactoryException otherwise.

It is also possible to configure logger name using this annotation:

private Logger logger;

If you do not specify it, then class name will be used as logger name.

If you want to specify mandatory for logger instantiation, use required parameter (default is true). Use @Log(required = false) to make your logger object optional (it could be useful in some rare cases).


  • Q: How to select protocol for Syslog4j?
    • A: Use @Log.name(), default protocol is "udp".
  • Q: How to configure Syslog4j with Herald?
    • A: Use standard Syslog4j API, ex: java final SyslogIF syslog = Syslog.getInstance("udp"); syslog.getConfig().setHost(""); syslog.getConfig().setPort(1514);


To build project in strict mode with tests, you can run:

mvn -P strict clean package

Might also like

  • jconditions - Extra conditional annotations for JUnit.
  • jackdaw - Java Annotation Processor which allows to simplify development.
  • houdini - Type conversion system for Java projects.
  • caesar - Library that allows to create async beans from sync beans.
  • commons-vfs2-cifs - SMB/CIFS provider for Commons VFS.
  • avconv4java - Java interface to avconv tool.


Copyright 2015 Vladislav Bauer

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

See [LICENSE](LICENSE) file for more details.

*Note that all licence references and agreements mentioned in the Herald README section above are relevant to that project's source code only.