How can I change the date format for Google's Flogger (fluent logging API for Java)?How to format date in java logging?SimpleFormatter ignoring the java.util.logging.SimpleFormatter.format propertyHow can I concatenate two arrays in Java?How can I get the current date and time in UTC or GMT in Java?How can I color Python logging output?How can I increment a date by one day in Java?How to get the current time in YYYY-MM-DD HH:MI:Sec.Millisecond format in Java?How to compare dates in Java?Change date format in a Java stringHow to get the current date/time in Javaslf4j: how to log formatted message, object array, exceptionHow to parse/format dates with LocalDateTime? (Java 8)
whey we use polarized capacitor?
How is it possible to have an ability score that is less than 3?
Why are 150k or 200k jobs considered good when there are 300k+ births a month?
Why was the small council so happy for Tyrion to become the Master of Coin?
Why don't electron-positron collisions release infinite energy?
How to make payment on the internet without leaving a money trail?
Can I interfere when another PC is about to be attacked?
Can a German sentence have two subjects?
What makes Graph invariants so useful/important?
Patience, young "Padovan"
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
How do I create uniquely male characters?
Work Breakdown with Tikz
Download, install and reboot computer at night if needed
What would happen to a modern skyscraper if it rains micro blackholes?
Motorized valve interfering with button?
Is there a familial term for apples and pears?
Is it possible to make sharp wind that can cut stuff from afar?
How long does it take to type this?
What is the logic behind how bash tests for true/false?
How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)
DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?
Possibly bubble sort algorithm
What is the command to reset a PC without deleting any files
How can I change the date format for Google's Flogger (fluent logging API for Java)?
How to format date in java logging?SimpleFormatter ignoring the java.util.logging.SimpleFormatter.format propertyHow can I concatenate two arrays in Java?How can I get the current date and time in UTC or GMT in Java?How can I color Python logging output?How can I increment a date by one day in Java?How to get the current time in YYYY-MM-DD HH:MI:Sec.Millisecond format in Java?How to compare dates in Java?Change date format in a Java stringHow to get the current date/time in Javaslf4j: how to log formatted message, object array, exceptionHow to parse/format dates with LocalDateTime? (Java 8)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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 HH:MM:SS.mmm" with 24-hour time format. Is there way to configure this? I don't have to use the Lombok annotation, it just seemed simpler.
Also, I wasn't able to find the flogger tag for this post.
java logging lombok java.util.logging
add a comment |
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 HH:MM:SS.mmm" with 24-hour time format. Is there way to configure this? I don't have to use the Lombok annotation, it just seemed simpler.
Also, I wasn't able to find the flogger tag for this post.
java logging lombok java.util.logging
Also, see the Google Flogger documentation and github links google.github.io/flogger and github.com/google/flogger
– timcassidy13
Mar 22 at 1:15
add a comment |
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 HH:MM:SS.mmm" with 24-hour time format. Is there way to configure this? I don't have to use the Lombok annotation, it just seemed simpler.
Also, I wasn't able to find the flogger tag for this post.
java logging lombok java.util.logging
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 HH:MM:SS.mmm" with 24-hour time format. Is there way to configure this? I don't have to use the Lombok annotation, it just seemed simpler.
Also, I wasn't able to find the flogger tag for this post.
java logging lombok java.util.logging
java logging lombok java.util.logging
edited Mar 22 at 2:37
jmehrens
6,93112134
6,93112134
asked Mar 22 at 0:49
timcassidy13timcassidy13
11
11
Also, see the Google Flogger documentation and github links google.github.io/flogger and github.com/google/flogger
– timcassidy13
Mar 22 at 1:15
add a comment |
Also, see the Google Flogger documentation and github links google.github.io/flogger and github.com/google/flogger
– timcassidy13
Mar 22 at 1:15
Also, see the Google Flogger documentation and github links google.github.io/flogger and github.com/google/flogger
– timcassidy13
Mar 22 at 1:15
Also, see the Google Flogger documentation and github links google.github.io/flogger and github.com/google/flogger
– timcassidy13
Mar 22 at 1:15
add a comment |
1 Answer
1
active
oldest
votes
From the output it looks like flogger is using SimpleFormatter from JUL. The format is controlled by setting the system property or define the key in the logging.properties. The formatter arguments are described in SimpleFormatter::format method. Keep in mind that the arguments in the documentation are off by one so the date parameter is actually %1
.
The syntax of the date formatting is described in java.util.Formatter.
Here is sample test program that can used to make sure your pattern compiles correctly when applied at runtime. One pattern that should work is: %1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n
.
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
public class Main
public static void main(String[] args) throws Exception
final String format = "%1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n";
final String key = "java.util.logging.SimpleFormatter.format";
test(format);
test(System.getProperty(key, format));
test(LogManager.getLogManager().getProperty(key));
private static void test(String format)
if (format != null)
LogRecord record = new LogRecord(Level.INFO, "");
System.out.println(String.format(format,
new java.util.Date(record.getMillis()),
record.getSourceClassName(),
record.getLoggerName(),
record.getLevel().getLocalizedName(),
record.getMessage(),
String.valueOf(record.getThrown())));
else
System.out.println("null format");
Which prints:
2019-03-21 21:51:08.604 null
INFO: null
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291331%2fhow-can-i-change-the-date-format-for-googles-flogger-fluent-logging-api-for-ja%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
From the output it looks like flogger is using SimpleFormatter from JUL. The format is controlled by setting the system property or define the key in the logging.properties. The formatter arguments are described in SimpleFormatter::format method. Keep in mind that the arguments in the documentation are off by one so the date parameter is actually %1
.
The syntax of the date formatting is described in java.util.Formatter.
Here is sample test program that can used to make sure your pattern compiles correctly when applied at runtime. One pattern that should work is: %1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n
.
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
public class Main
public static void main(String[] args) throws Exception
final String format = "%1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n";
final String key = "java.util.logging.SimpleFormatter.format";
test(format);
test(System.getProperty(key, format));
test(LogManager.getLogManager().getProperty(key));
private static void test(String format)
if (format != null)
LogRecord record = new LogRecord(Level.INFO, "");
System.out.println(String.format(format,
new java.util.Date(record.getMillis()),
record.getSourceClassName(),
record.getLoggerName(),
record.getLevel().getLocalizedName(),
record.getMessage(),
String.valueOf(record.getThrown())));
else
System.out.println("null format");
Which prints:
2019-03-21 21:51:08.604 null
INFO: null
add a comment |
From the output it looks like flogger is using SimpleFormatter from JUL. The format is controlled by setting the system property or define the key in the logging.properties. The formatter arguments are described in SimpleFormatter::format method. Keep in mind that the arguments in the documentation are off by one so the date parameter is actually %1
.
The syntax of the date formatting is described in java.util.Formatter.
Here is sample test program that can used to make sure your pattern compiles correctly when applied at runtime. One pattern that should work is: %1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n
.
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
public class Main
public static void main(String[] args) throws Exception
final String format = "%1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n";
final String key = "java.util.logging.SimpleFormatter.format";
test(format);
test(System.getProperty(key, format));
test(LogManager.getLogManager().getProperty(key));
private static void test(String format)
if (format != null)
LogRecord record = new LogRecord(Level.INFO, "");
System.out.println(String.format(format,
new java.util.Date(record.getMillis()),
record.getSourceClassName(),
record.getLoggerName(),
record.getLevel().getLocalizedName(),
record.getMessage(),
String.valueOf(record.getThrown())));
else
System.out.println("null format");
Which prints:
2019-03-21 21:51:08.604 null
INFO: null
add a comment |
From the output it looks like flogger is using SimpleFormatter from JUL. The format is controlled by setting the system property or define the key in the logging.properties. The formatter arguments are described in SimpleFormatter::format method. Keep in mind that the arguments in the documentation are off by one so the date parameter is actually %1
.
The syntax of the date formatting is described in java.util.Formatter.
Here is sample test program that can used to make sure your pattern compiles correctly when applied at runtime. One pattern that should work is: %1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n
.
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
public class Main
public static void main(String[] args) throws Exception
final String format = "%1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n";
final String key = "java.util.logging.SimpleFormatter.format";
test(format);
test(System.getProperty(key, format));
test(LogManager.getLogManager().getProperty(key));
private static void test(String format)
if (format != null)
LogRecord record = new LogRecord(Level.INFO, "");
System.out.println(String.format(format,
new java.util.Date(record.getMillis()),
record.getSourceClassName(),
record.getLoggerName(),
record.getLevel().getLocalizedName(),
record.getMessage(),
String.valueOf(record.getThrown())));
else
System.out.println("null format");
Which prints:
2019-03-21 21:51:08.604 null
INFO: null
From the output it looks like flogger is using SimpleFormatter from JUL. The format is controlled by setting the system property or define the key in the logging.properties. The formatter arguments are described in SimpleFormatter::format method. Keep in mind that the arguments in the documentation are off by one so the date parameter is actually %1
.
The syntax of the date formatting is described in java.util.Formatter.
Here is sample test program that can used to make sure your pattern compiles correctly when applied at runtime. One pattern that should work is: %1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n
.
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
public class Main
public static void main(String[] args) throws Exception
final String format = "%1$tF %1$tT.%1$tL %2$s%n%4$s: %5$s%6$s%n";
final String key = "java.util.logging.SimpleFormatter.format";
test(format);
test(System.getProperty(key, format));
test(LogManager.getLogManager().getProperty(key));
private static void test(String format)
if (format != null)
LogRecord record = new LogRecord(Level.INFO, "");
System.out.println(String.format(format,
new java.util.Date(record.getMillis()),
record.getSourceClassName(),
record.getLoggerName(),
record.getLevel().getLocalizedName(),
record.getMessage(),
String.valueOf(record.getThrown())));
else
System.out.println("null format");
Which prints:
2019-03-21 21:51:08.604 null
INFO: null
edited Mar 22 at 2:55
answered Mar 22 at 2:33
jmehrensjmehrens
6,93112134
6,93112134
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291331%2fhow-can-i-change-the-date-format-for-googles-flogger-fluent-logging-api-for-ja%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Also, see the Google Flogger documentation and github links google.github.io/flogger and github.com/google/flogger
– timcassidy13
Mar 22 at 1:15