diagnosing system with jax-rs

public class DiagnosesResource {

    private static final Logger logger
            = getLogger(DiagnosesResource.class.getName());

    private Response response() {
        return Response.ok(baos.toByteArray(), MediaType.TEXT_PLAIN).build();

    private void onPostConstruct() {
        baos = new ByteArrayOutputStream();
        formatter = new SimpleFormatter();
        handler = new StreamHandler(baos, formatter);

    private void onPreDestroy() {
        handler = null;
        formatter = null;
        baos = null;

    private ByteArrayOutputStream baos;

    private Formatter formatter;

    private Handler handler;

Now we can add some methods for diagnosing.

public Response some() {
    // diagnose here with some logs
    return response();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s