Skip to content

Instantly share code, notes, and snippets.

@4ndrej
Created August 14, 2020 13:51
Show Gist options
  • Save 4ndrej/5934e3c2179a500e896b186e97685eaf to your computer and use it in GitHub Desktop.
Save 4ndrej/5934e3c2179a500e896b186e97685eaf to your computer and use it in GitHub Desktop.
nginx yyyy-mm logging without if
http {
#access_log logs/access.log main;
# parse \d{4}-\d{2} from $time_iso8601 into $yyyy_mm
map $time_iso8601 $yyyy_mm {
"~^(?<temp>\d{4}-\d{2})" $temp;
}
server {
listen 80;
server_name _;
location / {
access_log logs/access-80-$yyyy_mm.log;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment