plone的结构化日志

ftw.structlog的Python项目详细描述


ftw.structlog

此包在plone中实现结构化请求登录。

它通过编写包含一个json条目的日志文件(每个实例一个)来实现 每行每一个请求。json条目包含 z2日志以结构化的键/值对提供了等等。

安装

  • 安装ftw.structlog,方法是将其添加到构建中的鸡蛋列表中。 然后运行buildout并重新启动实例:
[instance]eggs +=
    ftw.structlog
  • 或者,将其作为依赖项添加到包的setup.py

记录信息

示例条目:

{"bytes":6875,"cient_ip":"127.0.0.1","duration":0.30268411636353,"host":"127.0.0.1","method":"GET","referer":"http:\/\/localhost:8080\/plone","site":"plone","status":200,"timestamp":"2017-07-29T12:30:58.000750+02:00","url":"http:\/\/localhost:8080\/plone\/my-page","user":"john.doe","user_agent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/60.0.3112.113 Safari\/537.36"}

记录的json条目包含以下数据:

keyvalue
bytesSize of response body in bytes (^{tt3}$)
client_ipHost where the request originated from (respecting X-Forwarded-For)
durationTime spent in ZPublisher to handle request (time between ^{tt4}$ and ^{tt5}$ / ^{tt6}$ )
hostDeprecated. You should use ^{tt7}$ instead.
methodHTTP request method
refererReferer
sitePlone site ID
statusHTTP response status
timestampTime when request was received (non-naive local time in ISO 8601, in the server’s local timezone as determined by ^{tt8}$)
urlURL of the request (including query string if present)
userUsername of the authenticated user, ^{tt9}$ otherwise
user_agentUser-Agent

日志文件位置

将为每个zope2实例创建一个日志文件,以及它的位置和名称 将从实例的事件日志路径派生。如果实例的事件日志 路径是var/log/instance2.log,json日志文件的路径是 var/log/instance2-json.log

注意:因为ftw.structlog从 事件日志路径,必须在zope.conf中配置事件日志,否则 ftw.structlog不会记录任何请求并大声抱怨 根记录器。

在其他项目中运行测试时,可以通过设置 环境变量FTW_STRUCTLOG_MUTE_SETUP_ERRORS=true

更改日志

1.1.0(2019-01-11)

  • 已弃用:host字段已弃用。相反,新引进的 client_ip字段应用于获取客户端的IP地址。 [lgraf]
  • 总是将丢失的referer记录为空字符串,而不是null。 [lgraf]

1.0.1(2017-09-03)

  • 如果找不到事件日志配置以派生 从中记录位置。不是阻止实例启动,而是记录 使用根记录器时出现明显的错误消息。 [lgraf]

1.0.0(2017-09-03)

  • 初步实施 [lgraf]

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
@RequestMapping中的java Spring通配符作为@PathVariable   java Sonar违反if语句中未使用的方法   java如何重置Progressbar?   java需要澄清Dockerfile中的命令吗?   java Graphics2D对象以不同方式渲染同一对象的透明度   Java中泛型集合的循环迭代   java如何替换Plus。新playservicesauth:8.3.0和googleservices:1.5.0beta2中的PeopleApi?   java从绑定到数据库表的组合框中检索文本   awt Java交叉错误   java使用Paint object在安卓中创建字体和文本样式   找不到java TokenRegex文件错误   java JDBC Oracle数据库,准备好的语句中的编号参数意味着什么?   java访问switch语句中的对象   sql JAVA:如何减去当前时间和存储在数据库中的数据时间。?