我想记录我的传入/传出消息。目前,我能够记录整个消息,只需将 var taskListArray = new Array();
$(document).ready(function()
{
var addInput = $("#addInput");
var taskList = $("#taskList");
if(window.localStorage)
{
taskListArray = JSON.parse(window.localStorage.getItem("taskList"))
}
else
{
window.plugins.toast.showLongCenter("LocalStorage not found, saving unavailable!");
}
if(taskListArray != null)
{
for(i = 0; i < taskListArray.length; i++)
{
var task = "<li>" + taskListArray[i].task + "</li>";
taskList.append(task);
}
}
else
{
taskListArray = new Array();
}
$("#addButton").on("click", function()
{
if($("#addInput").val() != 0)
{
var task = "<li>" + addInput.val() + "</li>";
taskList.append(task);
taskListArray.push({task:addInput.val()});
if(window.localStorage)
{
window.localStorage.setItem("taskList", JSON.stringify(taskListArray));
}
addInput.val("");
window.plugins.toast.showShortCenter("Task added!");
}
});
$("li").dblclick(function()
{
//Removes last task instead of the task I double tapped on
//and I can't remove newly added tasks
taskListArray.splice($.inArray($(this), taskListArray), 1);
$(this).remove();
window.plugins.toast.showShortCenter("Task removed!");
if(window.localStorage)
{
window.localStorage.setItem("taskList", JSON.stringify(taskListArray));
}
});
});
添加到我的log4j2属性文件中。记录如下:
org.springframework.ws.client.MessageTracing.sent
我想按如下方式记录消息:
[TRACE] TIMESTAMP received - Received response [full message, very long and hard to read]
这里只是记录了带有参数的请求和响应,它们被发送/接收。更容易阅读!
怎么做?
答案 0 :(得分:0)
使用拦截器:
@Component
public class CustomEndpointInterceptor implements EndpointInterceptor {
private static final Log LOG = LogFactory.getLog(CustomEndpointInterceptor.class);
@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception {
LOG.info("Endpoint Request Handling");
return true;
}
@Override
public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception {
LOG.info("Endpoint Response Handling");
return true;
}
@Override
public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception {
LOG.info("Endpoint Exception Handling");
return true;
}
@Override
public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception {
LOG.info("Execute code after completion");
}
}
使用以下命令将其添加到您的配置中
@EnableWs
@Configuration
public class SoapServerConfig extends WsConfigurerAdapter {
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors) {
// register global interceptor
interceptors.add(new CustomEndpointInterceptor());
}
...
}