[英]How to decode the persisted log files from App Engine's Python Dev_server
Using Google App Engine's local dev_server, one of the published options is to save the log files to disk. 使用Google App Engine的本地dev_server,已发布的选项之一是将日志文件保存到磁盘。
"If you wish to persist the logs from the development server to disk at a location of your own >choosing, supply the desired path and filename to the --logs_path command line option as follows:
“如果您希望将日志从开发服务器保存到磁盘上自己选择的位置,请为--logs_path命令行选项提供所需的路径和文件名,如下所示:
dev_appserver.py --logs_path=your-path/your-logfile-name your-app-directory"
dev_appserver.py --logs_path =您的路径/您的日志文件名“您的应用程序目录”
This works except the files are in a binary format I can't decode. 除了文件是我无法解码的二进制格式之外,此方法均有效。
Google published some sample code but this is intended for an app to read the production logs. Google发布了一些示例代码,但这是供应用程序读取生产日志使用的。
Is there a command line utlity or python script that can decode the log files stored by the dev_server? 是否有命令行工具或python脚本可以解码dev_server存储的日志文件? This was submitted as a feature request in 2011.
这是在2011年作为功能请求提交的。
I can see the logs in the PyDev console as they are produced, but once the current execution is restarted, those logs are gone from that console. 我可以在PyDev控制台中看到生成的日志,但是一旦重新启动当前执行,这些日志就会从该控制台中消失。
There are some suggestions to pipe the logfile unix style, but this does not help with the logs already stored. 有一些建议可以使用管道文件unix样式,但这对已经存储的日志没有帮助。
The logfile created is a SQLite database. 创建的日志文件是一个SQLite数据库。 Use the
sqlite3
module to access it. 使用
sqlite3
模块进行访问。
The schema used is: 使用的架构是:
CREATE TABLE AppLogs (
id INTEGER NOT NULL PRIMARY KEY,
request_id INTEGER NOT NULL,
timestamp INTEGER NOT NULL,
level INTEGER NOT NULL,
message TEXT NOT NULL,
FOREIGN KEY(request_id) REFERENCES RequestLogs(id)
);
CREATE TABLE RequestLogs (
id INTEGER NOT NULL PRIMARY KEY,
user_request_id TEXT NOT NULL,
app_id TEXT NOT NULL,
version_id TEXT NOT NULL,
module TEXT NOT NULL,
ip TEXT NOT NULL,
nickname TEXT NOT NULL,
start_time INTEGER NOT NULL,
end_time INTEGER DEFAULT 0 NOT NULL,
method TEXT NOT NULL,
resource TEXT NOT NULL,
http_version TEXT NOT NULL,
status INTEGER DEFAULT 0 NOT NULL,
response_size INTEGER DEFAULT 0 NOT NULL,
user_agent TEXT NOT NULL,
url_map_entry TEXT DEFAULT '' NOT NULL,
host TEXT NOT NULL,
task_queue_name TEXT DEFAULT '' NOT NULL,
task_name TEXT DEFAULT '' NOT NULL,
latency INTEGER DEFAULT 0 NOT NULL,
mcycles INTEGER DEFAULT 0 NOT NULL,
finished INTEGER DEFAULT 0 NOT NULL
);
RequestLogs
contains HTTP requests (from a browser or a task queue); RequestLogs
包含HTTP请求(来自浏览器或任务队列); AppLogs
contains any logging entries recorded during a specific request. AppLogs
包含在特定请求期间记录的所有日志记录条目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.