Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
themeEclipse
titlelogging list content
linenumberstrue
    List<User> userList = reply.result().getResults();
 
  userList.size() < 3 ? logger.debug("Existing users: {}", userList) : 
      logger.debug("Number of existing users: {}", userList.size());
    
  if (LOGGER.isTraceEnabled()) {
    printFirstNElementsFromList(10, userList);
  }
  ...


  private void printFirstNElementsFromList(int numberElements, List listForPrint) {
    ....
  }

Big objects

Big objects should not be logged "as-is". If there's a need to log such an object, consider creating local wrapper, redefining toString() method within it, so it only contains most useful data from the object (id, referenced id's, maybe state)

...