如何解码App Engine的Python Dev_server中的持久日志文件 [英] How to decode the persisted log files from App Engine's Python Dev_server

查看:85
本文介绍了如何解码App Engine的Python Dev_server中的持久日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Google App Engine的本地dev_server,其中一个发布选项

a>是将日志文件保存到磁盘。


如果您希望将日志从开发服务器持久保存到磁盘的某个位置您可以选择--logs_path命令行选项提供所需的路径和文件名,如下所示:



dev_appserver.py --logs_path = your-path / your -logfile-name your-app-directory


这个工作除了文件是无法解码的二进制格式。 / p>

Google发布了一些示例代码,但这是为了让应用程序读取生产日志。



是否有命令行utlity或python脚本c解码由dev_server存储的日志文件?这是在2011年作为功能请求提交的。



我可以在PyDev控制台中看到它们生成时的日志,但是一旦当前执行重新启动,那些日志就会从该控制台中消失。



有一些建议来管理日志文件的unix风格,但这对于已存储的日志无效。

解决方案

创建的日志文件是一个SQLite数据库。使用 sqlite3 模块访问它。



使用的模式是:


$ b

  CREATE TABLE AppLogs(
id INTEGER NOT NULL PRIMARY KEY,
request_id INTEGER NOT NULL,
timestamp INTEGER NOT NULL,
level INTEGER NOT NULL,
消息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,
模块TEXT NOT NULL,
ip TEXT NOT NULL,
昵称TEXT NOT NULL,
start_time INTEGER NOT NULL,
end_time INTEGER DEFAULT 0 NOT NULL,
方法TEXT NOT NULL,
资源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,
延迟INTEGER DEFAULT 0 NOT NULL,
mcycles INTEGER DEFAULT 0 NOT NULL,
完成INTEGER DEFAULT 0 NOT NULL
);

RequestLogs 包含HTTP请求(来自浏览器或任务队列); AppLogs 包含特定请求期间记录的所有日志条目。


Using Google App Engine's local dev_server, one of the published options is to save the log files to disk.

"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:

dev_appserver.py --logs_path=your-path/your-logfile-name your-app-directory"

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.

Is there a command line utlity or python script that can decode the log files stored by the dev_server? This was submitted as a feature request in 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.

There are some suggestions to pipe the logfile unix style, but this does not help with the logs already stored.

解决方案

The logfile created is a SQLite database. Use the sqlite3 module to access it.

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); AppLogs contains any logging entries recorded during a specific request.

这篇关于如何解码App Engine的Python Dev_server中的持久日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆