1

When you log exceptions, does it get stored somewhere in a file? If so, how do I find this file? If not, why do people bother logging exceptions? I saw this example on the net:

DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        df.setLenient(false);

        try {
            //
            // Try to parsing a wrong date.
            //
            Date date = df.parse("12/30/1990");

            System.out.println("Date = " + date);
        } catch (ParseException e) {
            //
            // Create a Level.SEVERE logging message
            //
            if (logger.isLoggable(Level.SEVERE)) {
                logger.log(Level.SEVERE, "Error parsing date", e);
            }
        }

When I run it, I see the exception printed on my netbeans console, and I have to wonder, is that it, or is there more to this (there has to be)?

Thanks

3
  • yeah, that's the thing. Havent really found the right answer... :( What do i do in this case? Commented Mar 30, 2012 at 12:43
  • @AkinwaleAgbaje just looking at the answers provided to your questions, I saw at least 3 valid answers to 3 different questions. If you feel that they don't answer your question, you should probably reformulate them to be more accurate regarding what you expect. Regarding this question, you want explanations on logging but you don't mention how you instantiate your logger object, which logging framework you use and how it is configured. How do you expect people to provide more information based on this? Commented Apr 4, 2012 at 7:18
  • @Guilaume Polet If I knew which logger object to instantiate, which logging framework to use (didn't even know there were different ones to begin with. Just thought it was one, called Logger), and how to configure it, don't you think I would have put that in the question? Hell, I probably wouldn't have asked this question if I knew all of that! It's pretty clear from the question that I'm very new to logging. Christ, sorry for offending you. I'm going to tick an answer now Commented Apr 4, 2012 at 7:35

3 Answers 3

2

It all depends of your logging framework configuration. If you decide to use file appenders and that the log level is loggable, in most cases the exception stacktrace will be printed to a file.

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

Comments

1

If log4j is not configured properly the default logging of exceptions will be printing it on console. When configued to a file you can see the log information in the log file.

Comments

1

You need to configure your logging framework to log to a file.

You can again set the level of logging, file name and place and many more....

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.