Public methods on LogMessageParams

Class LogMessageParams contains the following public methods.
create()
Returns a new LogMessageParams data utility object, for example:
  • UserLogOn = LogMessageParams.create()
put(String, Object) Method adds the specified key-value pair to a LogMessageParams data utility object, for example:
UserLogOn.put("user", username)
         .put("userId", user.getID())
         .put("session", session.getId()))
put(LoggingKeyValue) Adds the key-value pair specified by a LoggingKeyValue object to a LogMessageParams data utility object. This action is similar to the action of the previous put method.
toString() Returns the formatted message to insert into the log record. For example, given the UserLogOn object defined previously, the following code…
  • UserLogOn.toString()
The method returns a message string that uses the following format…
  • {user="su", userId="3", session="qq0kis1ihdr11cq8r2ait576w"}

Parameter usage

It is also possible to add the same parameter two or more times to a LogMessageParams object. The LogMessageParams object stores all values for the given parameter added after the first parameter value in the following format:
  • paramName.number
For example, suppose that you have the following LogMessageParams.create method, which adds the same parameter (test) three times, with a different value each time:
LogMessageParams.create()
                .put("test", "1")
                .put("test", "2")
                .put("test", "3")
The resulting LogMessageParams object stores the following parameters:
  • "test", with a value of "1"
  • "test.1", with a value of "2"
  • "test.2", with a value of "3"