Skip to content

Instantly share code, notes, and snippets.

@bjpeterdelacruz
Created June 19, 2019 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjpeterdelacruz/d6f3c18a067dafe1826ffeee480cc458 to your computer and use it in GitHub Desktop.
Save bjpeterdelacruz/d6f3c18a067dafe1826ffeee480cc458 to your computer and use it in GitHub Desktop.
How to log a method in Java
public void doSomething(String recordId) {
log.debug("Deficiency list for recordId: {} - START", recordId);
Instant start = Instant.now();
try {
// do something
} finally {
Instant end = Instant.now();
Duration duration = Duration.between(start, end);
log.debug("Deficiency list for recordId: {} - END, millis: {}", recordId, duration.toMillis());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment