https://github.com/spring-projects/spring-boot/commit/c5cae282613d4229a8e4e9b0c3de5a1924d177a9 added support for plain text thread dump (https://github.com/spring-projects/spring-boot/issues/2339)
Issuing a http request without accepts: application/json (such as browser request) returns json format by default.
The json format is very hard to read by humans. For example, a stacktrace element has 8 fields (10 lines pretty formatted) so reading a stacktrace requires scrolling multiple pages...
{
"classLoaderName": null,
"moduleName": null,
"moduleVersion": null,
"methodName": "ajc$around$org_springframework_transaction_aspectj_AbstractTransactionAspect$1$2a73e96cproceed",
"fileName": "AbstractTransactionAspect.aj",
"lineNumber": 67,
"className": "org.springframework.transaction.aspectj.AbstractTransactionAspect",
"nativeMethod": false
},
The plain text format is more compact and easier to read by humans, and should be used by default instead. This way, when requesting the thread dump through browser it will be easier to read.
Comment From: wilkinsona
Thanks for the suggestion, but I'm not sure that this is possible.
There are two endpoint operations at the moment. One produces application/vnd.spring-boot.actuator.v3+json,application/vnd.spring-boot.actuator.v2+json,application/json and the other produces text/plain;charset=UTF-8. As far as I know, Spring MVC and WebFlux do not provide a way for use to assign weightings to the content types that are produced, i.e. if the Accept header doesn't express a preference, then we can't influence the decision. I believe that Jersey does support weightings via a qs attribute on the produced media types but we'd need something that works across all three web frameworks that the Actuator supports.
Is there a particular reason why you can't use a command line client or a browser plugin that allows you to control the accept header when making a request to the thread dump endpoint?
Comment From: cdalexndr
Is there a particular reason why you can't use a command line client or a browser plugin that allows you to control the accept header when making a request to the thread dump endpoint?
The request requires authorization (spring security), so after login page I get the threaddump on my browser. I rather make a custom endpoint for plain text threaddump than install a browser plugin for making a custom request.
Comment From: wilkinsona
We've discussed this and decided that this isn't a change that we want to make. You can achieve what you want with a little bit of your own code and, as explained above, the proposed change wouldn't be easy to make so the cost outweighs the benefit. Thanks anyway for the suggestion.
Comment From: barfoo4711
Sad that this was closed as won't fix. Therefore asking if there is a way/tooling to convert the produced json to plain text later on? I've googled around but not found anything so far.
Comment From: wilkinsona
Not that we're aware of. We recommend either making a request with an appropriate accept header or using the suggestion linked to above to force the text/plain response.