ToString method print String Objcet like Char array

时间:2019-04-08 14:02:41

标签: java logging apache-commons-lang3

I'm trying to log in to soap request, if my input is just a String object, ReflectionToStringBuilder build a log with my object splitted char by char. The strange thing is that if I have a String inside an Object It log well. How fix this ?

Code in java method, c is the single object to log:

  ToStringStyle style = new RecursiveToStringStyle();
  style = new MultilineRecursiveToStringStyle();
  logClass.append(ReflectionToStringBuilder.toString(c,style.MULTI_LINE_STYLE));    

Soap request example:

  <v12:serviceName>
     <v12:cod1>05034</v12:cod1>
     <v12:obj>
        <v13:objName>GOOGLE</v13:objName>
        <v13:objCode>123456789</v13:objCode>
     </v12:obj>
  </v12:serviceName>

Log result:

  2019-04-08 15:54:49,237 INFO  [null] - serviceName - INPUT:
  java.lang.String@ebbb509[
    value={0,5,0,3,4}
    hash=45955692
  ]
   obj@183ef29d[
   objName=GOOGLE
   objCode=123456789
  ]

Expected log result:

  2019-04-08 15:54:49,237 INFO  [null] - serviceName - INPUT:
  java.lang.String@ebbb509[
    value=05034
    hash=45955692
  ]
   obj@183ef29d[
   objName=GOOGLE
   objCode=123456789
  ]

0 个答案:

没有答案