Capture google app engine logging output

2019-04-11 10:23发布

How can one view the Google App Engine logs outside the Admin console?

I'm developing, so using dev_appserver.py/the Admin Console and would like to see the logs as the records are emitted.

I'd like to monitor the logging output in a console with standard Unix tools e.g. less/grep/etc, but there doesn't seem to be an option to direct the logging from the dev_appserver.py command, and I can't open a new file in GAE (e.g. a FileHandler), so file handlers won't work, and I think using a socket/udp handler would be a bit of overkill (if it's even possible).

I'm hopeful there are other options to view the log.

Thanks for reading.

2条回答
Summer. ? 凉城
2楼-- · 2019-04-11 10:25

You can download the logs using the request_logs parameter of appcfg.py

http://code.google.com/appengine/docs/python/tools/uploadinganapp.html#Downloading_Logs

Edit: This person came up with a way to send logs over XMPP. His solution is for GAE Java, but this could be adapted to python.

http://www.professionalintellectualdevelopment.com/

http://code.google.com/p/gae-xmpp-logger/

查看更多
你好瞎i
3楼-- · 2019-04-11 10:36

The default logger sends logging output to stderr. Use your shell's method of redirecting stderr to a file (in tcsh, (dev_appserver.py > /dev/tty) >& your_logfile.txt, your shell may vary.)

You can also use the logging module in python to change the logger to send directly to a file if you detect it's running locally (os.environ['SERVER_SOFTWARE'].startswith('Dev'))

查看更多
登录 后发表回答