C
C
codecity2010-12-30 21:11:22
Google Workspace
codecity, 2010-12-30 21:11:22

Google App Engine and printStackTrace -- how to log

Is there a standard way to display Exception.printStackTrace() information in the Google App Engine log (control panel)?

For some reason, I was sure that it was written there by default and actively used it. And now you need to either redo everything, or find how to turn it on.

I have been working with Java recently, please do not kick with your feet.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
B
barker, 2010-12-30
@barker

Well, in general, the standard printStackTrace writes to System.err => should get into the application logs. Where exactly are you looking? Does everything from System.out / System.err get there?

D
Dimonich, 2010-12-31
@Dimonich

Try to just rewrite the entire stack to a standard logger.

        try {
            //Some code
        } catch (Exception e) {
            for (StackTraceElement ste : e.getStackTrace()) {
                log.error(e.toString());
            }
        }

C
codecity, 2010-12-31
@codecity

By the way, interestingly, System.out.print ln ("test") appears in the logs. But System.out.print("test") is not. If you add the characters "\r\n" at the end of the line, it starts to appear. The same goes for System.err. Looks like a bug in Google...

C
codecity, 2010-12-31
@codecity

In general, the solution is:

PrintStream printStream = new PrintStream(System.err, true, "UTF-8");
exception.printStackTrace(printStream);

There were no problems with Russian characters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question