The toString method of the object in the java log log, what do you use to implement it?

output objects in the log, usually using toString, what is the implementation of this method? It must not be handwritten.
is there a better choice for the one we use?

public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
May.08,2021

  1. Lombok @ ToString
  2. JSON.toJSONString ()

of course, it is maintenance-free with Lombok, and you have to change


to save the addition and subtraction of fields.

at present, I use the following traditional way in my work

ToStringBuilder.reflectionToString(this);

Lombok is recommended.


better choice: do not output objects

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45fde-438b4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45fde-438b4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?