How to change the date format of the logger

109 views
Skip to first unread message

timcas...@gmail.com

unread,
Mar 21, 2019, 7:52:22 PM3/21/19
to Flogger Discuss
I'm trying the Lombok @Flogger feature which is supposed to add the below when annotating the class with @Flogger.

private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();

See the little documentation on it. https://projectlombok.org/features/log

I added the below log to a method:
log.atInfo().log("This is my info message");


And the output that I see in the console is:
Mar 21, 2019 7:35:05 PM net.domain.Class myMethod
INFO: This is my info message


I'd prefer a YYYY-MM-DD with 24-hour time format.  Is there way to configure this?  I don't have to use the Lombok annotation, it just seemed simpler.

Nicholas Glorioso

unread,
Mar 22, 2019, 9:32:56 AM3/22/19
to timcas...@gmail.com, Flogger Discuss
Some context that's helpful to answer this question:

Flogger is the logging API that defines the code you use in your application (as in your example above with log.atInfo().log...).
The logging backend is the code that takes the log entries and shuffles them off to your console, log files, etc. This code is generally what's responsible for the formatting and display of your log files (specifically, the format that you want to change).

Unless your application is specially configured, the default logging backend that Flogger uses is the one built into Java, aka Java Util Logging.

There are myriad routes and ways to configure the JUL system (more explicit documentation here), but a couple of options I've found include:
Hope this helps!


--
You received this message because you are subscribed to the Google Groups "Flogger Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flogger-discu...@googlegroups.com.
To post to this group, send email to flogger...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flogger-discuss/4144cce1-5580-4114-93dd-75c13c6b25eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages