trinity/logger

Trinity Logger 扩展包

安装次数: 4,110

依赖关系: 2

建议者: 0

安全性: 0

星标: 0

关注者: 16

分支: 0

开放问题: 0

类型:symfony-bundle

v1.1.19 2017-12-13 12:00 UTC

README

此扩展包是为新的 Elasticsearch (v5) 重建的,且 README 文件尚未更新。待办事项

Coverage Status Build Status

用于在 Elasticsearch 数据库中存储和加载日志的扩展包。

如果您发现有问题未按预期工作,请提交问题。

Logger 会每天创建一个新的索引,格式为 YYYY-MM-DD。它与环境一起工作,目前使用两种类型。开发和生产日志写入同一个索引。测试环境在索引前添加前缀 'test-'。

因此,可以直接通过 URL 查看日志

http:\\elastic_host:port\YYYY-MM-DD\LogName\LogId

例如

trinity_logger:
  elastic_logs:
    elastic_host: '127.0.0.1:9200'
    managed_index: 'necktie'

当调用方法时,可以更改配置的索引。

经典调用

$this->get('trinity.elastic.read.log.service')->getCount('ExceptionLog');

调用不同的索引

$this->get('trinity.elastic.read.log.service')->setIndex('venice')->getCount('ExceptionLog');

对于搜索,需要知道实体类存储的位置。大多数类存储在相同的位置,因此可以将它们按以下方式添加到配置中

trinity_logger:
  elastic_logs:
    elastic_host: '127.0.0.1:9200'
    managed_index: 'necktie'
    entities_path: 'Necktie\\AppBundle\\Entity'

当我们使用 nqlQuery(有关更多信息,请参阅 trinity/search)时,可以调用

$entities = $this->get('trinity.elastic.read.log.service')->getByQuery($nqlQuery);

如果实体定义存储在其他位置,例如

$entities = $this->get('trinity.elastic.read.log.service')
    ->setEntityPath('Necktie\\PaymentBundle\\Entity')
    ->getByQuery($nqlQuery);

注意:ElasticSearch 是 noSQL 数据库.... NO!!! SQL 因此它只支持一个实体下的查询。如果您需要连接某些内容,请使用基于关系的 SQL 数据库。

由于此扩展包的主要用途目前是 Necktie,以下值用作默认值,无需配置。managed_index: 'necktie' entities_path: 'Necktie\AppBundle\Entity'