Spring Boot Actuator provides several endpoints to monitor an application as:
/metrics
/b
Do the following:
@Configuration
public class JacksonConfig {
@Autowired
private ObjectMapper objectMapper; //reuse the pre-configured mapper
@PostConstruct
public void setup() {
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
//whatever else you need
}
}
This works because Spring Boot uses an ObjectMapper
bean to perform all the JSON related operations.
Note however that this configuration will pretty print all JSON outputs, not just the actuator related stuff.
UPDATE
The answer from @DaveSyer is obviously better! I hadn't found the HttpMapperProperties
object which is used to configure Jackson. This is it's Javadoc