Google App Engine: Logging in dev console? - google-app-engine

Does logging work on the dev server? This code doesn't raise an exception, but I can't see where to view the logs in the devserver console. Perhaps I'm looking in the wrong place?
logging.error("error has occurred")

Make sure you create your logger. This should work.
Code
import logging
logging.getLogger().setLevel(logging.DEBUG)
logging.error("uuu")
logging.info("ggg")
Launching from the CLI
$dev_appserver.py ~/workspace/helloworld/
The logs I got on the CLI...
ERROR 2012-11-26 03:02:25,467 helloworld.py:89] uuu
INFO 2012-11-26 03:02:25,467 helloworld.py:90] ggg
Note that this also works for me in Tornado.

Yes, logging works on the dev server. When dev_appserver.py is run from the command-line, you should see output from logging calls such as the one you mentioned whenever they are called.
By default, only logging messages of INFO level and higher are printed.
Also, logging.error() does not raise an exception when called. It simply logs the string you pass at the "error" level - on the development server, this basically just means it will print "ERROR" as part of the logging message on the development server.

You can configure the default logging level when starting the development server:
dev_appserver.py --log_level=debug ...
From dev_appserver.py command-line arguments:
--log_level=...
The lowest logging level at which logging messages will be written to the console; messages of the specified logging level or higher will
be output. Possible values are debug, info, warning, error, and
critical.

Related

Failed to start tomcat.service: Unit tomcat.service is not loaded properly: Invalid argument

Failed to start tomcat.service: Unit tomcat.service is not loaded properly: Invalid argument.
See system logs and 'systemctl status tomcat.service' for details.
I have checked many times it is not working.
I don't know exact comands but for me it was a permission issue.
I gave permissions to user tomcat but tried to run service as default user.
Look for read/write permission and make sure you have them correctly.

dev_appserver.py slow start

After some time I needed to do changes on GAE Python (2.7) First Generation app, but when I develop and run locally, it's basically nonusable due to a very slow start.
These are printed logs:
INFO 2019-10-18 07:56:35,533 devappserver2.py:278] Skipping SDK update check.
INFO 2019-10-18 07:56:35,595 api_server.py:275] Starting API server at: http://localhost:36159
INFO 2019-10-18 07:56:35,599 dispatcher.py:270] Starting module "default" running at: http://127.0.0.1:8080
INFO 2019-10-18 07:56:35,600 admin_server.py:152] Starting admin server at: http://localhost:8000
INFO 2019-10-18 08:01:01,644 instance.py:294] Instance PID: 28496
What I notice that the last line (instance.py) is printed after ~5 minutes and only after that app responds to requests, not before. Interesting that the admin server (localhost:8000) is available right away. Of course, when I do some code change it automatically reloads and it repeats again.
Things I tried/found out:
it behaves like that on my all GAE projects Python First Gen.
tried to create a bare minimal version (webapp2 with one URL), clean virtualenv, still the same behavior
tried to reinstall Google Cloud SDK. delete the whole google-cloud-sdk folder and install again, no changes
tried to install older version of Cloud SDK
used clean VM and it works ok!!!, so it looks like there could be something wrong with my system (outside of SDK), but I'm not sure what.
It's interesting that the pause between the last two log lines is always about 5 minutes, not sure why exactly that time.
Python 2.7.14
OS: OpenSuse Leap 15.0
I'm running out of ideas so any advice would be appreciated.
I solved this accidentally.
I wanted to run Jupyter notebook, but I got the error:
error: [Errno 99] Cannot assign requested address
after debugging in /tornado/netutil.py, I noticed that it tries to work with IP 192.168.1.50 which I wasn't sure where did that come from, (probably I set it since I was playing with my home network some time ago), but when I deleted it from /etc/hosts, Jupyter, as well as GAE, works ok.
What a coincidence :)

What is CrashLoopBackOff status for openshift pods?

There is more than one example where I have seen this status from a pod running in openshift origin. In this case it was the quickstart for the cdi camel example. I was able to successfully build and run it locally (non - openshift) but when I try to deploy on my local openshift (using mvn -Pf8-local-deploy), I get this output for that particular example (snipped for relevance) :-
[vagrant#vagrant camel]$ oc get pods
NAME READY STATUS RESTARTS AGE
cdi-camel-z4czs 0/1 CrashLoopBackOff 4 2m
Tail of the logs are as under:-
Error occurred during initialization of VM
Error opening zip file or JAR manifest missing : agents/jolokia.jar
agent library failed to init: instrument
Can someone help me solve this ?
If the state of the pod goes in to CrashLoopBackOff it usually indicates that the application within the container is failing to start up properly and the container is exiting straight away as a result.
If you use oc logs on the pod name, you may not see anything useful though as it would capture what the latest attempt to start it up is doing and may miss messages.
What you should do is instead provide the --previous or -p option to oc logs along with the pod name. That will show you the complete logs from the previous attempt to start up the container.
If this is an arbitrary Docker image you are using, a common problem that can occur and which would cause the container not to start, is an application image which requires to be run as the root user. Because running an application inside of a container as root still has risks, OpenShift doesn't allow you to do that by default and will instead run as an arbitrary assigned user ID. The application image may not be designed with this possibility in mind and so is failing.
So try and get those logs messages and see what the problem is.
Temporary workaround -> https://github.com/fabric8io/ipaas-quickstarts/issues/1157
Basically, the src/main/hawt-app directory needs to be deleted.

DSpace error with oai import

After configuring my DSpace server, its working correctly but when I look at the OAI identify page (http://repositorio.puce.edu.ec/oai/request?verb=Identify) so we can be harvested, it says that the repository is localhost instead of my URL. I investigated and found out that to update this, I have to run this command: dspace/bin/dspace oai import -c but when I run that command is gives me the following error: Solr server (http://repositorio.puce.edu.ec/solr/oai) is down, turn it on.
I can see the Solr Admin (it can't be seen from the outside because of security reasons) so I don't know what should be turned on or how to do it?
Thanks for the help.
I encountered this error in the past.
Looking at my oai.cfg file, I used localhost for some settings and my public URL for others.
solr.url=http://localhost/solr/oai
# OAI persistent identifier prefix.
# Format - oai:PREFIX:HANDLE
identifier.prefix = repository.library.georgetown.edu
# Base url for bitstreams
bitstream.baseUrl = https://repository.library.georgetown.edu
If you need to make a config change, be sure to clear the cache after restarting service.

dev_appserver returns error "unexpected port response from runtime"

Last week, I have successfully tried the Helloworld example with sdk release 1.7.6 and python 2.7 on Windows XP SP3. Today it will not run at all and generates this error.
Can anybody help?
D:\helloworld>dev_appserver.py d:\helloworld
INFO 2013-03-24 20:16:18,187 sdk_update_checker.py:244] Checking for updates
to the SDK.
INFO 2013-03-24 20:16:19,062 sdk_update_checker.py:272] The SDK is up to dat
e.
INFO 2013-03-24 20:16:19,421 api_server.py:152] Starting API server at: http
://localhost:1868
INFO 2013-03-24 20:16:19,437 dispatcher.py:98] Starting server "default" run
ning at: http ://localhost:8080
INFO 2013-03-24 20:16:19,483 admin_server.py:117] Starting admin server at:
http ://localhost:8000
ERROR 2013-03-24 20:16:29,717 http_runtime.py:221] unexpected port response f
rom runtime ['before instance\r\n']; exiting the development server
INFO 2013-03-24 20:16:30,546 api_server.py:517] Applying all pending transac
tions and saving the datastore
INFO 2013-03-24 20:16:30,546 api_server.py:520] Saving search indexes
Could you please file a bug at:
https://code.google.com/p/googleappengine/issues/list
Also, have you added any print statements to the libraries in your Python installation?
Tim Hoffman's response:
"""Check you do not have any print statements in your code. If you do they will write to stdout which the new dev server doesn't like as it uses stdin/stdout to talk between the main task and the workers.""" is not correct. Your application can print to stdout and stderr. In your case it looks like something is printing to stdout before your application is loaded.
Check you do not have any print statements in your code. If you do they will write to stdout which the new dev server doesn't like as it uses stdin/stdout to talk between the main task and the workers. You can read more on how the new dev server functions - and how debugging with pdb etc will have to work
You can run the old version of the server by instead running old_dev_appserver.py

Resources