【问题标题】:Setup Nginx logs to directly imports in Piwik设置 Nginx 日志以直接导入 Piwik
【发布时间】:2014-04-15 15:53:33
【问题描述】:

我已经安装 Piwik 并且工作正常,但我想配置 Nginx 以在创建日志时直接导入日志,从而防止解析日志文件。

我知道这可以在 Apache 中使用以下方法完成:

# Log to piwik as well
CustomLog "|/path/to/import_logs.py --option1 --option2 ... -" myLogFormat

但我在 Nginx 上找不到类似的东西。

有人知道怎么做吗?

【问题讨论】:

    标签: logging nginx matomo


    【解决方案1】:

    这在 Nginx 中是不可能的,请参阅 this post in the mailing list

    不,nginx 不支持记录到管道,因为这是 simlpy 浪费CPU。你可以试试 tail -F /path/to/log |应用程序这几乎 与管道日志一样浪费 CPU。

    如果你想知道它为什么慢:

    Logging to pipe is a CPU waste because it causes a lot of context switches 
    and memory copies for every log operation: 
    
    1) nginx writes to a pipe, 
    2) context switch to script, 
    2) script reads from the pipe, 
    3) script processes line, 
    4) script writes to a database, 
    5) context switch to nginx. 
    
    instead of single memory copy operation to a log file. 
    

    您必须创建另一个脚本来运行和跟踪日志文件,然后将数据通过管道传输到 Piwik。

    【讨论】:

      猜你喜欢
      • 2014-12-05
      • 2012-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多