Closed huny0501 closed 1 year ago
You have already an analysis of the issue from the leshan project.
But you didn't answer the question, where you call the "logger" (or where the logger gets called).
Please add the class and line number of that log statement.
And, maybe, if you want to see to complete Payload of the ReadResponse, you may also ask in Leshan, if that's possible there. Maybe you just use the ReadResponse itself instead of the "ReadResponse.getCoapResponse()".
Thanks... I will check more :)
Just to mention:
If your code calls the LOGGER, an easy way would be:
if (MediaTypeRegistry.isPrintable( response.getOptions().getContentFormat())) {
LOGGER.info("{} : {}", response, response.getPayloadString());
} else {
LOGGER.info("{} : {}", response);
}
(that only works, if the payload has a printable content format)
If you use a MessageInterceptor
e.g. MessageTracer
you will need to provide a custom version.
Years ago, we decided to "truncate" the payload for logging in order to save resources. The main purpose of the Californium internal logging is to see, if the RFC 7252 is obeyed. Considering the payload is then more the focus on the next layer. To be frank, I don't know, why you need to log the complete payload. Unless you use a blockwise transfer, CoAP is straight forward. When you start to use blockwise then I'm also not aware of any issue, at least not when the response is reassembled and forwarded as response.
So, maybe you also tell, what you're searching for.
I made a simple application using leshan&californium. So there is no a lot of payload log so I wanna see whole of logs :)
I am using "org.eclipse.leshan.core.response.ReadResponse" I display ReadResponse directly. Yes I can see whole of payload, but it is not json format. I wanna see SenML Json Format, sorry
I succeeded to see whole of log by changing the source code. I attached californium-core 3.9.0 source instead of jar(lib) and changed it.
protected String getPayloadTracingString() { // Display payload until 3072 byte return StringUtil.toDisplayString(payload, 3072); }
I succeeded but I think it is not efficient Is this for the best? Can I set this from Californium.properties OR on so on...? If there is no more method, I will use it :D
So there is no a lot of payload log so I wanna see whole of logs :)
Yes, that's your usage. And others have other requirements.
I display ReadResponse directly. Yes I can see whole of payload, but it is not json format.
I'm confused. What should that mean?
I succeeded but I think it is not efficient Is this for the best? Can I set this from Californium.properties OR on so on...? If there is no more method, I will use it :D
There is no property to change the toString()
behavior.
For the very very most user, it is too easy to prepare the content of the logging for their requirement exactly when the logger is called. That's simply straight forward and very common. So, as long as you don't show the code, where the logger is called in your case, it's just too time consuming to try to help you.
OK Thanks! Thank you all the time :)
Hello, I am using leshan server demo.
I wanna save the whole logs of SenML JSON.
But, I can see small part of SenML Logs, As follows. I am using "ReadResponse.getCoapResponse()" method
As you know, I wanna see whole SenML JSON.
Is it possible?
If it is possible, How can I do it?
I will wait your reply :)