【问题标题】:wkhtmltopdf writes in apache error log for every pdf createdwkhtmltopdf 为每个创建的 pdf 写入 apache 错误日志
【发布时间】:2015-09-22 03:28:27
【问题描述】:

每次在 WKHTMLTOPDF(使用 php)中创建 PDF 时,我都会在 apache 错误日志中得到以下信息:

Loading pages (1/6)
[>                                                           ] 0%
[======>                                                     ] 10%
[==========>                                                 ] 17%
[===================>                                        ] 32%
[==============================>                             ] 50%
[=====================================>                      ] 63%
[============================================>               ] 74%
[============================================================] 100%
Counting pages (2/6)                                               
[============================================================] Object 1 of 1
Resolving links (4/6)                                                       
[============================================================] Object 1 of 1
Loading headers and footers (5/6)                                           
Printing pages (6/6)
[>                                                           ] Preparing
[============================================================] Page 1 of 1
Done                                                                      

然而创建的 pdf 没有任何错误,有没有办法阻止这种情况,因为错误日志变得非常大并且还掩盖了真正的错误?

谢谢

【问题讨论】:

    标签: php apache pdf wkhtmltopdf error-log


    【解决方案1】:

    专门让 wkhtmltopdf 静音:

    1. 使用--quiet 标志:

       exec("wkhtmltoimage -q …");
      
    2. 并根据 2>/dev/null 或类似的 shell 功能重定向 stderr

       exec("wkhtmltopdf -q … 2>&1");
      

    后者适用于大多数命令行工具,顺便说一句。

    【讨论】:

    • 已确认。 '-q' 标志确实使日志静音。文档说要使用--log-level error,但这会产生异常。
    猜你喜欢
    • 2013-12-27
    • 1970-01-01
    • 2011-05-24
    • 1970-01-01
    • 2019-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-24
    相关资源
    最近更新 更多