Google AppEngine Dev Server 上的 KMS - 日志记录混乱
Google KMS on AppEngine Dev Server - logging clutter
This is a known issue: https://issuetracker.google.com/issues/63253097
除了 ,我将提出一个关于相关但有问题的副作用的新问题。
也就是说,Google Cloud API 发现似乎想要在 AppEngine 沙箱之外走很多路。这本身不是问题,但它使测试和调试变得非常有问题,因为每次尝试都会被记录下来,产生数百行,如下所示:
INFO 03 Jul 2017 14:44:51 Sandbox prevented access to file "/Users"
INFO 03 Jul 2017 14:44:51 If it is a static file, check that application_readable: true
is set in your app.yaml
INFO 03 Jul 2017 14:44:52 Sandbox prevented access to file "/usr/lib/Acrobat9/Resource/CMap"
INFO 03 Jul 2017 14:44:52 If it is a static file, check that application_readable: true
is set in your app.yaml
INFO 03 Jul 2017 14:44:52 Sandbox prevented access to file "/usr/lib/Acrobat8/Resource/CMap"
INFO 03 Jul 2017 14:44:52 If it is a static file, check that application_readable: true
is set in your app.yaml
有没有办法禁用或静音这些请求或日志?
EDIT* 通过将 traceback.print_stack()
添加到 stub.py
中的 log_access_check_fail
打印的众多结果之一(抱歉,这里不是很清晰) :
测试 #1:Sentry.io 的 Raven 导入 pkg_resources
File "/Users/bmh/testapp/application.py", line 3, in <module>
from nassau.application import app, sentry
File "/Users/bmh/testapp/nassau/application.py", line 28, in <module>
from raven.contrib.flask import Sentry
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/raven/__init__.py", line 16, in <module>
VERSION = __import__('pkg_resources') \
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3037, in <module>
@_call_aside
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3021, in _call_aside
f(*args, **kwargs)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3050, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 646, in _build_master
ws = cls()
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 639, in __init__
self.add_entry(entry)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 695, in add_entry
for dist in find_distributions(entry, True):
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2006, in find_on_path
path_item = _normalize_cached(path_item)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2217, in _normalize_cached
_cache[filename] = result = normalize_path(filename)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2210, in normalize_path
return os.path.normcase(os.path.realpath(filename))
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 375, in realpath
path, ok = _joinrealpath('', filename, {})
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 400, in _joinrealpath
if not islink(newpath):
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 135, in islink
st = os.lstat(path)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 286, in __call__
log_access_check_fail(path)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 51, in log_access_check_fail
traceback.print_stack()
我删除了对 Sentry / Raven 的依赖,但堆栈跟踪仍在继续,通过:
测试 #2:Flask 导入 pkgutil
File "/Users/bmh/testapp/application.py", line 3, in <module>
from nassau.application import app
File "/Users/bmh/testapp/nassau/application.py", line 72, in <module>
app = Flask('nassau')
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/flask/app.py", line 331, in __init__
instance_path = self.auto_find_instance_path()
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/flask/app.py", line 622, in auto_find_instance_path
prefix, package_path = find_package(self.import_name)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/flask/helpers.py", line 661, in find_package
loader = pkgutil.get_loader(root_mod_name)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader
return find_loader(fullname)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 475, in find_loader
loader = importer.find_module(fullname)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 184, in find_module
path = [os.path.realpath(self.path)]
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 375, in realpath
path, ok = _joinrealpath('', filename, {})
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 400, in _joinrealpath
if not islink(newpath):
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 135, in islink
st = os.lstat(path)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 286, in __call__
log_access_check_fail(path)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 51, in log_access_check_fail
traceback.print_stack()
必须有更好的方法来表示堆栈溢出的堆栈跟踪:)
对我来说,这些消息似乎源自一个名为 stubs.py 的 GAE (.local) 文件。
在我的第一个案例中,stubs.py 正在寻找不存在的文件。所以您可能想要检查“/usr/lib/Acrobat8/Resource/CMap”是否确实存在。然后,从stubs.py开始,尝试找出what file is trying to load it.
我的项目正在使用 web.py,突然间我又开始收到 (stubs.py) 消息,这次是关于 .pyc 文件的。我在 app.yaml 文件的底部放了一个 skip_files:,它确实抑制了消息,但我还没有测试我的应用程序是否仍然可以完全编译。
skip_files:
- ^(.*/)?\.pyc$
更多关于 Python GAE 运行时和沙箱的信息。
https://cloud.google.com/appengine/docs/standard/python/runtime
我是 dev_appserver 的全职工程师。
此日志消息来自 /google/appengine/tools/devappserver2/python/stubs.py,方法 log_access_check_fail
我们添加此日志消息是为了提醒用户 dev_appserver 阻止文件访问的行为。
推荐的解决方法:
dev_appserver.py --log_level 警告
--log_level 设置本地 python 运行时进程中的日志级别。 log_access_check_fail() 设置为 INFO 并且不会被记录。注意,此标志还将阻止您的应用程序中的其他 INFO 级别日志记录。
与此同时,我们正在修复此 log_access_check_fail 方法。它可能会将 log_access_check_fail() 日志记录级别降低到 DEBUG。
这很烦人,有一个bug report。
与此同时,我们可以过滤掉这些消息,但我们需要弄清楚它们正在使用哪些 logger
。有关如何处理日志记录的更多信息,请参阅 the docs。查看 stubs.py
的源代码,我发现:
logging.info('Sandbox prevented access to file "%s"', filename)
logging.info('If it is a static file, check that '
'`application_readable: true` is set in your app.yaml')
所以他们正在使用根记录器(通常是不好的做法)。要在您的根记录器上过滤掉这些消息,请将以下内容添加到您的 appengine_config.py
:
import logging
class StubsFilter(logging.Filter):
def filter(self, record):
return 'stubs.py' != record.filename
logging.root.addFilter(StubsFilter())
This is a known issue: https://issuetracker.google.com/issues/63253097
除了
也就是说,Google Cloud API 发现似乎想要在 AppEngine 沙箱之外走很多路。这本身不是问题,但它使测试和调试变得非常有问题,因为每次尝试都会被记录下来,产生数百行,如下所示:
INFO 03 Jul 2017 14:44:51 Sandbox prevented access to file "/Users"
INFO 03 Jul 2017 14:44:51 If it is a static file, check that
application_readable: true
is set in your app.yamlINFO 03 Jul 2017 14:44:52 Sandbox prevented access to file "/usr/lib/Acrobat9/Resource/CMap"
INFO 03 Jul 2017 14:44:52 If it is a static file, check that
application_readable: true
is set in your app.yamlINFO 03 Jul 2017 14:44:52 Sandbox prevented access to file "/usr/lib/Acrobat8/Resource/CMap"
INFO 03 Jul 2017 14:44:52 If it is a static file, check that
application_readable: true
is set in your app.yaml
有没有办法禁用或静音这些请求或日志?
EDIT* 通过将 traceback.print_stack()
添加到 stub.py
中的 log_access_check_fail
打印的众多结果之一(抱歉,这里不是很清晰) :
测试 #1:Sentry.io 的 Raven 导入 pkg_resources
File "/Users/bmh/testapp/application.py", line 3, in <module>
from nassau.application import app, sentry
File "/Users/bmh/testapp/nassau/application.py", line 28, in <module>
from raven.contrib.flask import Sentry
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/raven/__init__.py", line 16, in <module>
VERSION = __import__('pkg_resources') \
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3037, in <module>
@_call_aside
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3021, in _call_aside
f(*args, **kwargs)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3050, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 646, in _build_master
ws = cls()
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 639, in __init__
self.add_entry(entry)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 695, in add_entry
for dist in find_distributions(entry, True):
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2006, in find_on_path
path_item = _normalize_cached(path_item)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2217, in _normalize_cached
_cache[filename] = result = normalize_path(filename)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2210, in normalize_path
return os.path.normcase(os.path.realpath(filename))
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 375, in realpath
path, ok = _joinrealpath('', filename, {})
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 400, in _joinrealpath
if not islink(newpath):
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 135, in islink
st = os.lstat(path)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 286, in __call__
log_access_check_fail(path)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 51, in log_access_check_fail
traceback.print_stack()
我删除了对 Sentry / Raven 的依赖,但堆栈跟踪仍在继续,通过:
测试 #2:Flask 导入 pkgutil
File "/Users/bmh/testapp/application.py", line 3, in <module>
from nassau.application import app
File "/Users/bmh/testapp/nassau/application.py", line 72, in <module>
app = Flask('nassau')
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/flask/app.py", line 331, in __init__
instance_path = self.auto_find_instance_path()
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/flask/app.py", line 622, in auto_find_instance_path
prefix, package_path = find_package(self.import_name)
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/site-packages/flask/helpers.py", line 661, in find_package
loader = pkgutil.get_loader(root_mod_name)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader
return find_loader(fullname)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 475, in find_loader
loader = importer.find_module(fullname)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 184, in find_module
path = [os.path.realpath(self.path)]
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 375, in realpath
path, ok = _joinrealpath('', filename, {})
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 400, in _joinrealpath
if not islink(newpath):
File "/Users/bmh/testapp/python-virtualenv/lib/python2.7/posixpath.py", line 135, in islink
st = os.lstat(path)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 286, in __call__
log_access_check_fail(path)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 51, in log_access_check_fail
traceback.print_stack()
必须有更好的方法来表示堆栈溢出的堆栈跟踪:)
对我来说,这些消息似乎源自一个名为 stubs.py 的 GAE (.local) 文件。
在我的第一个案例中,stubs.py 正在寻找不存在的文件。所以您可能想要检查“/usr/lib/Acrobat8/Resource/CMap”是否确实存在。然后,从stubs.py开始,尝试找出what file is trying to load it.
我的项目正在使用 web.py,突然间我又开始收到 (stubs.py) 消息,这次是关于 .pyc 文件的。我在 app.yaml 文件的底部放了一个 skip_files:,它确实抑制了消息,但我还没有测试我的应用程序是否仍然可以完全编译。
skip_files: - ^(.*/)?\.pyc$
更多关于 Python GAE 运行时和沙箱的信息。 https://cloud.google.com/appengine/docs/standard/python/runtime
我是 dev_appserver 的全职工程师。
此日志消息来自 /google/appengine/tools/devappserver2/python/stubs.py,方法 log_access_check_fail
我们添加此日志消息是为了提醒用户 dev_appserver 阻止文件访问的行为。
推荐的解决方法: dev_appserver.py --log_level 警告
--log_level 设置本地 python 运行时进程中的日志级别。 log_access_check_fail() 设置为 INFO 并且不会被记录。注意,此标志还将阻止您的应用程序中的其他 INFO 级别日志记录。
与此同时,我们正在修复此 log_access_check_fail 方法。它可能会将 log_access_check_fail() 日志记录级别降低到 DEBUG。
这很烦人,有一个bug report。
与此同时,我们可以过滤掉这些消息,但我们需要弄清楚它们正在使用哪些 logger
。有关如何处理日志记录的更多信息,请参阅 the docs。查看 stubs.py
的源代码,我发现:
logging.info('Sandbox prevented access to file "%s"', filename)
logging.info('If it is a static file, check that '
'`application_readable: true` is set in your app.yaml')
所以他们正在使用根记录器(通常是不好的做法)。要在您的根记录器上过滤掉这些消息,请将以下内容添加到您的 appengine_config.py
:
import logging
class StubsFilter(logging.Filter):
def filter(self, record):
return 'stubs.py' != record.filename
logging.root.addFilter(StubsFilter())