New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Google Flogger #1697

omaric opened this Issue May 21, 2018 · 3 comments


None yet
3 participants

omaric commented May 21, 2018

Sorry if this is the wrong place for feature requests.

Lombok is great, and the concept of @Log and other loggers is very good. However, out of the many logger options, it doesn't include the best logger: Flogger. Compare the other loggers:

  • Log, Log4j, and CommonsLog have no support for parameters at all
  • Log4j2, Slf4j, and XSlf4j use {} instead of %s. This can be confusing when you have String.format() statements in the same file.
  • JBossLog isn't Flogger

Flogger is very fast (including optimized parameterized logging) and includes features like:

// Log 1 in 100 messages to avoid spamming the logs.
logger.atInfo().every(100).log("My message", args);
// Log at most once every 5 seconds.
logger.atInfo().atMostEvery(5, SECONDS).log("My message", args);
// This obviates the need to create exceptions just to see the stack

Thanks for consideration.


This comment has been minimized.


rzwitserloot commented May 28, 2018

example desugar:

public class Example {
    private static final logger =;


  • The primary utility of lombok's logging annotations is to get around the fact that you have to violate DRY by having to re-specify your own class name in the logging field. However, flogger works around this by making an expensive call to a stack trace retrieval method to obtain it. The theory presumably being that the # of classes you initialize during any given JVM run is small enough that the cost of doing this is just not relevant, and I'm tempted to agree with them on sheer principles, let alone the fact that one would assume a company like google of all places would have given this some experimentation in addition to some thought.

We can add it.. not sure it's worth the effort for you to use it, but for consistency's sake, eh. It's an hour or two, mostly to write the requisite documentation and config keys.

There's no way to provide a name, the above code is the only way, and there's nothing you can feasibly configure.


This comment has been minimized.

omaric commented May 29, 2018

I didn't realize that was the reasoning behind the log annotations. I thought it was to reduce boilerplate.

Are you certain the stack trace call is expensive? I ask because everything else in Flogger is highly optimized, and the main two operations are a single, cached reflective Class.forName() call, and a Throwable.getStackTrace() call, which should be quicker than the expensive Thread.getStackTrace.

I would definitely use it if it were added to Lombok, as I have used it in other projects. I think other users might enjoy it, too. :)


This comment has been minimized.


Maaartinus commented May 29, 2018

Are you certain the stack trace call is expensive?

I can't speak for him, but I'm sure, it's relatively expensive. It'd very bad for performance when done for every log line, but it hardly matters when done once per class. I guess, it can (and will) be optimized using JEP 259, but I'd bet, hardly anybody will notice.

rzwitserloot added a commit that referenced this issue Jun 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment