days
1
5
hours
2
1
minutes
0
5
seconds
2
6
search

Flogger: A new fluent logging API for Java

Jane Elizabeth
Flogger
© Shutterstock / M-SUR

Self-documenting log statements may be what first caught our eye, but Flogger, a new fluent logging API for Java, has a lot to offer for developers looking to manage their logging better.

Managing logs isn’t easy. But thanks to a new fluent logging API for Java, Flogger makes it even easier to manage logs and find errors wherever they might be hiding.

Flogger

Flogger joins a crowded field of Java logging APIs: there are lots of specialist debug logging APIs out there for Google’s codebase. So why add to the pile? Well, Flogger is intended to be a generalist logging API, suitable for most Java projects in Google.

Flogger is a somewhat verbose logging API, but don’t let the additional typing scare you. This API makes it even easier to gather more information from event logging than classical logging APIs.

With one method call, developers can:

  • Specify the log level (via the choice the method itself)
  • Optionally attach metadata to the log statement (the cause)
  • Specify the log message and arguments

Flogger has a number of other benefits over other APIs. For one, logging at disabled levels is effectively free. Developers can add as many fine-grained log statements to their code as they want, without worry. It also has very high performance for enabled log statements.

Additionally, a fluent API accommodates a variety of present and future features without combinatorial explosion, and without requiring separate logging facades. There’s also less reliance on long parameter lists makes it harder to misuse and yields more self-documenting code.

SEE MORE: Forget cloud standardization – we need a Logging API in Java

Get Flogger

Flogger brings readability to high performance logging, with extensibility and a reduced cost of disabled log statements.

It’s easy to start using this new logging API for Java in three simple steps:

  1. Add an import for FluentLogger
  2. Create a private static final instance
  3. Start logging!

If you’re interested about learning more, head on over to their website – they have a lot of information available about Flogger, its benefits, best practices, and even the anatomy of a logging API for a deeper dive into the rationale behind this new logger. Head on over to their GitHub page to see more!

Author
Jane Elizabeth
Jane Elizabeth is an assistant editor for JAXenter.com.

Leave a Reply

1 Comment on "Flogger: A new fluent logging API for Java"

avatar
400
  Subscribe  
Notify of
Ben M
Guest

I’m still unclear about what flogger IS. Is this an API that uses an underlying framework to do the actual logging (slf4j) or if it actually performs the logging (logback/log4j2). In EITHER case it’s not documented on how to actually use the library. If the first, how do i bind to a backend? If the latter how do i configure my actual log appenders??