How to write to the console in Google App Engine?

Often when I code, I just like to print small things (basically the current value of the variables) for the console. I don’t see anything like this for the Google App Engine, although I note that the Google App Engine Launcher has a log terminal. Is there a way to write to a Terminal or some other terminal using the Google App Engine?

+45
python google-app-engine logging
Apr 07 '09 at 20:14
source share
10 answers

You want to use the standard logging module of Python.

 import logging logging.info("hello") logging.debug("hi") # this won't show up by default 

To see the logging.debug() calls in the GoogleAppEngineLauncher Logs console, you must first add the --dev_appserver_log_level=debug flag to your application. However, be careful that you see a lot of noise debugging the App Engine SDK itself. complete set of levels :

  • debug
  • info
  • warning
  • error
  • critical

You can add a flag by double-clicking the application and then dropping it in the Additional flags field.

Adding the -dev_appserver_log_level flag to your application in GoogleAppEngineLauncher

+63
Mar 12 2018-12-12T00:
source share

See https://cloud.google.com/appengine/docs/python/requests#Python_Logging
and http://docs.python.org/library/logging.html

You probably want to use something like:

 logging.debug("value of my var is %s", str(var)) 
+31
Apr 7 '09 at 20:23
source share

@Manjoor

You can do the same in java.

 import java.util.logging.Logger; // ... public class MyServlet extends HttpServlet { private static final Logger log = Logger.getLogger(MyServlet.class.getName()); public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { log.info("An informational message."); log.warning("A warning message."); log.severe("An error message."); } } 

See “Registering” at http://code.google.com/appengine/docs/java/runtime.html

+9
Dec 07 '10 at 18:54
source share

If you are using a newer version of Python Development Server (releases> 1.7.6 or Mar 2013 and later), these are apparently the right steps to use:

  • Include the following in a script,

    import logging logging.debug("something I want to log")

  • And for this page of documents, set the flag by choosing "Edit"> "Application Settings"> "Launch Options"> "Flags of additional commands", and adding,

    --log_level=debug

+4
Mar 17 '14 at 23:53
source share

You should also take a look at FirePython. It allows you to receive server log messages in firebug.

http://appengine-cookbook.appspot.com/recipe/firepython-logger-console-inside-firebug/

+2
Apr 07 '09 at 23:49
source share

Check out my online Python interpreter running on the Google App Engine on my website, Learn Python . Perhaps this is what you are looking for. Just use print repr (variable) for the things you want to see, and do as many times as you want.

+1
Aug 30 2018-11-11T00:
source share

Hello, I am using version 1.8.6 of GoogleAppEngineLauncher, you can use the flag to set the level of the message log that you want to see, for example, for debugging messages:

--dev_appserver_log_level debug

Use it instead of --debug (see @Christopher answer).

+1
Nov 22 '13 at 18:37
source share

GAE will log a standard error and print it on the console or in a log.

 print >> sys.stderr, "Something to log." 
0
Jul 24 '13 at 19:10
source share

Use log.setLevel (Level.ALL) to view messages

The default message filtering level seems like an “error”. I did not see any useful log messages until I used the setLevel () method to make .info and .warning messages visible.

Text printed in System.out also did not display. This seems to be interpreted as log.info () level messaages.

0
Sep 24 '13 at 16:30
source share

I hope I answer this question. Log messages are printed in the AppEngine log, not in the terminal.

You can start it by clicking the log button in the AppEngine Launcher

0
Jan 6 '16 at 10:36
source share



All Articles