doutuo7609
2016-02-21 00:10
浏览 318
已采纳

php-fpm写巨大的日志文件

in /usr/local/nginx/logs/ I have a huge www.access.log file.

It grows undefinitely (last time I truncated it was 3.5 GB) with a new log entry every time a php script is called.

Every line looks like this:

- -  21/Feb/2016:00:59:09 +0100 "GET /index.php" 200 /absoulute-path/index.php 10,373 1280 96,40%

The file is written by php-fpm process

Browsing thru the various configuration files (nginx, php.ini....) I cannot find the directive to write logs to that file.

How can I disable it?

图片转代码服务由CSDN问答提供 功能建议

/ usr / local / nginx / logs /

我有一个巨大的 www.access.log 文件。

每次调用php脚本时,它都会无限期地增长(上次我将其截断为3.5 GB)并使用新的日志条目。

每一行都如下所示:

   -   -  21 / Feb / 2016:00:59:09 +0100“GET /index.php  “200 /absoulute-path/index.php 10,373 1280 96,40%
   
 
 

该文件由 php-fpm 进程<编写 / p>

浏览各种配置文件(nginx,php.ini ....)我找不到将日志写入该文件的指令。

如何禁用它?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dqz7636 2016-02-21 02:02
    已采纳

    Given the format and the informations provided in the sample log entry posted in the question the huge log file has nothing (directly) to do with nginx nor with its configuration files, despite it's located in .../nginx/logs/

    That ....access.log file is written by php-fpm worker processes when a specific option is set into php-fpm's configuration file php-fpm.conf

    The file (on my server) is located into /etc/

    At some point in the configuration file there is:

    ; The access log file
    ; Default: not set
    ; access.log = /usr/local/nginx/logs/$pool.access.log
    

    By default that option is not set and should remain unset; as far as I know the log file it produces is used to test php-fpm proper operation.

    If the line is uncommented by removing the semicolon...

    ; The access log file
    ; Default: not set
    access.log = /usr/local/nginx/logs/$pool.access.log
    

    ...then a .access.log file prefixed with the pool name (www in the case exposed in the question) is generated. And it grows quickly as each time a php script is run due to a request a new log entry is appended.

    点赞 打赏 评论
  • douyu9433 2016-02-21 00:22

    You have to change the nginx.conf configuration file in this way:

    server {
       (...)
       access_log off;
    }
    

    nginx.conf is located in /usr/local/nginx/conf, /usr/local/etc/nginx or /etc/nginx



    Edit: see also How to disable Nginx logging, Disable access logging and ngx_http_log_module

    点赞 打赏 评论
  • dongmou9260 2016-02-21 01:07

    Disable this is not a good practice .

    Those files can give your very sensitive and informative information about your site visitor .

    You can make some changes to make log files take a smaller space and easy to maintain.

    You can make compression , Log Rotation to avoid filing up disk space and manage your log files .

    Please check this link.

    点赞 打赏 评论

相关推荐 更多相似问题