0

I am calling a web service using the following code

public static ServResponse enGenderAndSentiment(String url, Tweet t) {

        HttpClient httpClient = new DefaultHttpClient();
        String responseBody = "";
        ServResponse holder = null;

        try {
            # calling a web service here
        } catch (Exception ex) {
            logger.debug("Exception while calling api for : " + t.getId());
            logger.debug(ex);
        } finally {
            httpClient.getConnectionManager().shutdown();
        }       

        return holder;

    }

An exception is thrown while executing the previous code and when I check the log file, I found the message Exception while calling ... but I the exception itself is not logged.

What could be the problem here? why the second logging statement is not printing anything in the log file?

7
  • 1
    Can you show us the log? Commented Aug 24, 2017 at 13:16
  • Could be happening because of your logger, is the current level > debug? try to simply printStackTrace and see what you got. Commented Aug 24, 2017 at 13:22
  • @MehdiB. Huh? On a server? What makes you think that printing a stack trace to the console would be visible anywhere? Commented Aug 24, 2017 at 13:26
  • 1
    @GhostCat, Websphere does print the stack trace on the sys err log file. Commented Aug 24, 2017 at 13:27
  • @MehdiB. but that assumes he is using websphere ... Commented Aug 24, 2017 at 13:41

1 Answer 1

1

Use logger.error(ex,ex); instead of logger.debug(ex); to log also the stacktrace (with optional cause exceptions)...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.