천상나타의 일상다반사

닫기 검색결과 전체 보기

    Nginx logformat json 구조로 남기기

    IT/Server 2023. 2. 3. 10:39

    nginx 로그를 카프카로 전송에 용이하게 로그를 json  구조로 남길 필요가 있었다.

    json 구조로 남기는 부분을 기록한다.

    nginx에서 지원하는 변수 리스트

    http://nginx.org/en/docs/varindex.html

     

    Alphabetical index of variables

     

    nginx.org

    nginx 로그 sample

    http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format

     

    Module ngx_http_log_module

    Module ngx_http_log_module The ngx_http_log_module module writes request logs in the specified format. Requests are logged in the context of a location where processing ends. It may be different from the original location, if an internal redirect happens d

    nginx.org

     

    실제 작업시 nginx 설정

    http {
    
      log_format json_format escape=json  '{"proxy_add_x_forwarded_for":"$proxy_add_x_forwarded_for",'
                                                       '"remote_user_ip":"$remote_user",'
                                                       '"time_local":"[$time_local]",'
                                                       '"request":"$request",'
                                                       '"status":"$status",'
                                                       '"body_bytes_sent":"$body_bytes_sent",'
                                                       '"http_referrer":"$http_referer",'
                                                       '"http_user_agent":"$http_user_agent",'
                                                       '"request_time":"$request_time",'
                                                       '"upstream_response_time":"$upstream_response_time",'
                                                       '"userid":"$cookie__userId",'
                                                       '"request_body":"$request_body"}';
    }

     

    format을 지정한다.

    access_log /var/log/nginx/admin-nata-access.log json_format;

    실제 로그가 json구조로 남는것을 확인 할 수 있다.

    'IT > Server' 카테고리의 다른 글

    라즈베리 파이에서 GUI VNC에서 한글꺠짐현상 변경  (0) 2023.04.03
    라즈베리 파이 GUI 원격데스크톱 VNC 연결하기  (0) 2023.04.03
    오라클 무료 클라우드 서비스 소개  (0) 2023.02.22
    [톰켓] tomcat에서의 OutOfMemoryError 발생시 자동 Heap 덤프 생성 방법.  (0) 2017.08.17
    [톰켓] JConsole을 통한 원격지 모니터링 환경설정  (0) 2017.06.08

    'IT/Server' 관련 글 more
    • thumbnail
      라즈베리 파이 GUI 원격데스크톱 VNC 연결하기 2023.04.03
    • thumbnail
      오라클 무료 클라우드 서비스 소개 2023.02.22
    • [톰켓] tomcat에서의 OutOfMemoryError 발생시 자동 Heap 덤프 생성 방법. 2017.08.17
    • thumbnail
      [톰켓] JConsole을 통한 원격지 모니터링 환경설정 2017.06.08
    Posted by 천상나타

Google Translate

Naver Neighborhood

    최근...

  • 포스트
  • 댓글
  • 더 보기

글 보관함

«   2025/05   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

카테고리

분류 전체보기 (393)
IT (130)
JAVA (19)
JSP (5)
NoSql (8)
Linux (5)
javaScript (13)
Oracle (7)
MySql (2)
Android (1)
Spring (8)
Server (19)
System (13)
Tool (30)
공부자료(비공개) (0)
일상 (258)
맛집 (69)
해외여행 (31)
국내여행 (21)
우리집 고양이 쪼꼬 (4)
디저트&야식 (49)
영화 후기 (2)
제품리뷰 (5)
추천노래 (3)
취미 (74)
다이어트 (0)
유용한정보 (5)
블로그팁 (4)
지역정보 (1)

카운터

Total
Today
Yesterday
  • 네이버 이웃추가
  • 방명록
천상나타's Blog is powered by daumkakao
Skin info material T Mark 5+ by 뭐하라
favicon

천상나타의 일상다반사

IT정보공유 및 일상다반사

  • 네이버 이웃추가
  • 방명록

관리자 메뉴

  • 관리자 모드
  • 글쓰기
  • 분류 전체보기 (393)
    • IT (130)
      • JAVA (19)
      • JSP (5)
      • NoSql (8)
      • Linux (5)
      • javaScript (13)
      • Oracle (7)
      • MySql (2)
      • Android (1)
      • Spring (8)
      • Server (19)
      • System (13)
      • Tool (30)
      • 공부자료(비공개) (0)
    • 일상 (258)
      • 맛집 (69)
      • 해외여행 (31)
      • 국내여행 (21)
      • 우리집 고양이 쪼꼬 (4)
      • 디저트&야식 (49)
      • 영화 후기 (2)
      • 제품리뷰 (5)
      • 추천노래 (3)
      • 취미 (74)
      • 다이어트 (0)
    • 유용한정보 (5)
      • 블로그팁 (4)
      • 지역정보 (1)

카테고리

PC화면 보기 티스토리 Daum

티스토리툴바