日志输出对象的属性值
在接口接收对象的时候往往要在日志打印出接收到的对象。如果直接toString()的话是没用的。可以用阿里的json工具类的JSON.toString()方法。
import com.alibaba.fastjson.JSON;
if (logger.isInfoEnabled() && batchAuthVO != null) { logger.info("接收到前台的批量授权信息:{}", JSON.toJSONString(batchAuthVO)); }
输出结果:
2018-04-1615: 36: 25,
2362502992[http-nio-8082-exec-9]INFOc.e.e.s.a.web.AuthController-接收到前台的批量授权信息:{
"endDate": 1555400102000,
"groupIds": ["d0f6c2a55c9c47f585a6b0de61913af7",
"f2484bfff4fd41709cc270f8ec7489f2"],
"personList": [{
"authFlag": 0,
"userId": "264bc1118cd34821a162de29b8dc511e",
"userName": "周明",
"userType": 1
},
{
"authFlag": 0,
"userId": "0d9270f410da4dabb3382755b141fed5",
"userName": "孙洲周",
"userType": 3
}],
"startDate": 1523864094000
}