Skip to Content
Suffering builds character
아카이브8.Nginx특징로깅3. 특정 경로에는 로깅 제외하기

3. 특정 경로에는 로깅 제외하기

요청 경로에 따라 로깅이 필요하지 않은 경우에는 로깅을 수행하지 않도록 적용할 수 있음

terminal
events {} http { include mime.types; server { # skip.. location /no-log { access_log off # off 값을 통해 로깅을 수행하지 않도록 적용 return 200 'no-log route'; } } }

테스트를 위해 acccess.log 파일 내용 초기화

terminal
echo '' > access.log

설정 파일 재적용 후 해당 경로로 접근 테스트

terminal
curl localhost/no-log no-log route
terminal
cat access.log # → /no-log 경로는 off 옵션이 적용되었기 때문에 로그가 기록되지 않음
💡
Tip

로그 메시지 커스터마이징하기

필요에 따라 로그 메시지의 출력 포맷을 커스터마이징할 수 있음

참고 링크
https://docs.nginx.com/nginx/admin-guide/monitoring/logging/ https://nginx.org/en/docs/http/ngx_http_log_module.html https://nginx.org/en/docs/ngx_core_module.html#error_log

Last updated on