nginx - Nginx - 在 access.log 中记录一个可能未初始化的变量
问题描述
我的设置如下:
位置.conf
location /foo {
set $x "foo"
}
location /foo2 {
set $notX "foo2"
}
nginx.conf
http {
..
..
log_format access_format $x
access_log /var/log/nginx/access.log access_format ;
..
..
}
当我点击 /foo 时,访问日志会正确打印,但是当我访问 /foo2 时,日志会打印在 error.log 中,但有异常
using uninitialized "x" variable while logging request
我尝试在其中添加 if 条件location.conf
,nginx.conf
但这会导致配置无效。我还尝试使用nginx.conf
下面的 map 来默认值,但这也无济于事
http {
..
..
map $x $new_x {
'' "dummy"
default $x
}
log_format access_format $new_x
access_log /var/log/nginx/access.log access_format ;
..
..
}
解决方案
推荐阅读
- r - 在 R Shiny 中将 dropdownButton 包装在 absolutePanel 中
- sycl - intel sycl 支持提前编译和交叉编译ARM?
- spring - Spring Web Security Config - 忽略 CSRF 验证
- node.js - 如何在一对多关系中显示详细信息
- swiftui - NavigationView 总是创建一个新视图
- laravel - 当我想在此代码中更新时,出现 404 错误
- c - 在声明中迭代没有大小的结构数组
- c# - Roslyn 有没有办法将所有依赖项与生成的应用程序捆绑在一起
- php - 如何获取现有行位置的文件名?
- android - 下载管理器不断下载第一个 apk 并缓存它