a5sys/monitor-bundle

安装: 575

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 4

分支: 1

开放问题: 0

类型:symfony-bundle

V1.0.0 2016-12-19 13:50 UTC

This package is auto-updated.

Last update: 2024-08-27 17:41:55 UTC


README

此包提供一些关于应用程序使用的统计信息。

您可以轻松地知道,每天

  • 有多少请求没有结束
  • 慢请求
  • 影响您应用程序性能的请求

安装

下载

使用composer下载包

composer require 'a5sys/monitor-bundle'

启用包

在您的 /app/AppKernel.php 中启用该包

new A5sys\MonitorBundle\MonitorBundle(),

注意,您还需要启用 jms-translation 包

new JMS\TranslationBundle\JMSTranslationBundle(),

添加频道

配置记录器

monolog:
    channels: ['monitor']
    handlers:        
        monitor:
    	    type:  rotating_file
            max_files: 60
    	    path:  "%kernel.logs_dir%/monitor.log"
            channels: ['monitor']
    	    formatter: monitor.monolog.formatter

如果您不想在主日志中过多记录,请不要忘记从主日志中移除 monitor 频道。

示例

monolog:
    handlers:
        main:
            type: rotating_file
            max_files: 60
            path:   "%kernel.logs_dir%/%kernel.environment%.log"
            level:  debug
            channels: [!'monitor']

路由

在您的 app/config/routing.yml 中设置路由

monitor_controller:
    resource: "@MonitorBundle/Controller/"
    type:     annotation
    prefix:   /monitor

安全

在您的 app/config/security.yml 中设置安全

security:
    access_control:
        - { path: ^/monitor/, roles: ROLE_SUPER_ADMIN }

配置

以下是可用的配置及其默认值

monitor:
    enable: true #enable or disable the logs
        slow_threshold:
        	warning: 1000 #the requests that needs more than X ms is a slow one
        	error: 3000 #the requests that needs more than X ms is an error, it takes too much time
types:
	start: true #is the start time for the request log required
	stop: true #is the stop time for the request log required
	duration: true #is the duration for the request log required
	memory: true #is the memory for the request log required
	url: true #is the url for the request log required
	user: true #is the user for the request log required

用法

监控日志位于您的 app/logs 文件夹中。

统计信息可以在以下URL查看(取决于您的配置)

http://yourapp/monitor