error-log-write: Conditional error log entries in configuration
Debian/Ubuntu installation
These docs apply to the APT package nginx-module-error-log-write provided by the GetPageSpeed Extras repository.
- Configure the APT repository as described in APT repository setup.
- Install the module:
sudo apt-get update
sudo apt-get install nginx-module-error-log-write
Show suites and architectures
| Distro | Suite | Component | Architectures |
|----------|-------------------|-------------|-----------------|
| debian | bookworm | main | amd64, arm64 |
| debian | bookworm-mainline | main | amd64, arm64 |
| debian | trixie | main | amd64, arm64 |
| debian | trixie-mainline | main | amd64, arm64 |
| ubuntu | focal | main | amd64, arm64 |
| ubuntu | focal-mainline | main | amd64, arm64 |
| ubuntu | jammy | main | amd64, arm64 |
| ubuntu | jammy-mainline | main | amd64, arm64 |
| ubuntu | noble | main | amd64, arm64 |
| ubuntu | noble-mainline | main | amd64, arm64 |
ngx_http_error_log_write_module allows writing error log entries based on conditional expressions in nginx configuration files..
Table of Content
Status
This Nginx module is currently considered experimental. Issues and PRs are welcome if you encounter any problems.
Synopsis
error_log_write level=info message="main test log";
server {
listen 127.0.0.1:80;
server_name localhost;
error_log_write message="server test log" if=$arg_test;
location / {
error_log_write level=warn message="auth required" if!=$http_authorization;
auth_baisc "auth required";
auth_basic_user_file conf/htpasswd;
proxy_pass http://example.upstream.com;
}
}
Directives
error_log_write
Syntax: error_log_write [level=log_level] message=text [if=condition];
Default: -
Context: http, server, location
Writing a new error log. All error log entries are inherited unconditionally from the previous configuration level.