lighty 的生活

lighty 开发者博客

日志条件处理,调试的隐藏功能

lighttpd 1.4.x 系列引入了许多功能以改进配置文件处理。但有一个未被文档化但却很棒的功能,用于调试。

它最初是为了供开发者内部调试新的条件缓存系统而实现的。

但我发现它对用户调试条件如何匹配很有用,可以查看操作符两侧的两个值以及它们是否匹配。一个新的补丁已被提交,使其更便于您使用。

  1. 只需在您的配置中添加或取消注释:debug.log-condition-handling = “enable”。
  2. 重启您的 lighttpd,或者使用 sbin/lighttpd -Df lighttpd.conf 启动它。
  3. 请求 URL,并检查 error.log,如果您未指定 error.log,则检查 stderr。

./sbin/ligittpd -pf test.conf

config {
  var.PID                      = 25629
  var.CWD                      = "/usr/src/lighttpd/branches/lighttpd-merge-1.4.x"
  server.modules               = ("mod_indexfile", "mod_staticfile")
  server.port                  = 8080
  server.document-root         = "/tmp"
  debug.log-condition-handling = "enable"
  
  
  $HTTP["useragent"] =~ "MSIE" {
    # block 1
  
  } # end of $HTTP["useragent"] =~ "MSIE"
}

./sbin/lighttpd -Df test.conf

2006-04-02 13:40:05: (src/log.c.75) server started 
2006-04-02 13:40:07: (src/response.c.150) run condition 
2006-04-02 13:40:07: (src/configfile-glue.c.404) === start of 1 condition block === 
2006-04-02 13:40:07: (src/configfile-glue.c.356)
HTTP["useragent"] ( Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) ) compare to MSIE 
2006-04-02 13:40:07: (src/configfile-glue.c.419) 1 result: true

另请参阅:1.4.x 中的高级配置, lighttpd 揭秘第一部分, lighttpd 揭秘第二部分