Skip to content

Instantly share code, notes, and snippets.

@4ndrej
Created August 14, 2020 13:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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