UBUNTU 웹서버

[APACHE] 아파치 로그에 이미지 제외하기


[APACHE] 아파치 로그에 이미지 제외하기


  2021-10-10  482 View 공개

제목입력

Gallery

 유튜브 영상


www.retrogames.cc


추천 블로그

태그



참고자료 (Reference)

박스

박스



추천 블로그

제목입력

참고자료 (Reference)

태그

 유튜브 영상


www.retrogames.cc


Gallery

추천 블로그

 유튜브 영상


www.retrogames.cc




태그

참고자료 (Reference)

박스

Gallery

제목입력

 유튜브 영상


www.retrogames.cc


추천 블로그

태그

제목입력

박스

참고자료 (Reference)

Gallery



Apache를 이용하여 웹 서비스를 하다보면 사용자의 접속로그등이 서버에 누적되게 된다.
이 로그를 기본으로 사용할 경우 1개 페이지의 접속에 대하여 상당히 많은양의 로그를 남기게 되는데, 예를들어 A라는 사용자가 HTML로 구성된 1.jsp를 호출한다고 하였을때 아파치 로그는 1.jsp 안에 포함되어 있는 모든 이미지, css, js 등을 모두 접속로그로 기록하게 된다.

이러한 이유로 log의 크기가 급격하게 커지게 되고, 이는 서비스의 영향을 줄 수도 있는만큼 상황에 따라 적절하게 적용하면 좋다.


특정항목들에 대해 로그 기록을 제외시킬수 있는데, 오늘은 이미지를 제외시키는 방법을 예제로 확인해 보겠다.


1. log_config_module 수정

우선 ${Apache_HOME}/conf/httpd.conf 파일을 열어 아래와 같은 항목을 찾은후 노란색 부분을 추가해 준다.



    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat '%h %l %u %t \'%r\' %>s %b \'%{Referer}i\' \'%{User-Agent}i\'' combined
    LogFormat '%h %l %u %t \'%r\' %>s %b' common

   
      # You need to enable mod_logio.c to use %I and %O
      LogFormat '%h %l %u %t \'%r\' %>s %b \'%{Referer}i\' \'%{User-Agent}i\' %I %O' combinedio
   

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per- access logfiles, transactions will be
    # logged therein and *not* in this file.
    #

    
    SetEnvIf Request_URI \.gif image-request
    SetEnvIf Request_URI \.jpg image-request
    SetEnvIf Request_URI \.png image-request
    SetEnvIf Request_URI \.bmp image-request
    SetEnvIf Request_URI \.swf image-request

    
    CustomLog 'logs/access_log' common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog 'logs/access_log' combined
 




2. Custom Log 설정


virtual host 등 로그설정부분에서 다음과 같이 combined env 를 추가한다. 


CustomLog '|/usr/local/cronlog/sbin/cronolog /usr/local/apache/logs/192.168.0.1-access_%Y%m%d.log' combined env=!image-request





출처: https://fruitdev.tistory.com/161 [과일가게 개발자]


Tags  #Apache  



🚩 UBUNTU 웹서버 글 모음 (총 14 건)

[APACHE] 아파치 로그에 이미지 제외하기

Last Updated : 2022-05-20
#Apache

[UBUNTU] APACHE2 설치

Last Updated : 2021-11-01
#Apache

[APACHE] 아파치 로그 로테이션 (rotetalogs)

Last Updated : 2021-10-15
#Apache

[APACHE] 아파치 로그파일 형식 지정

Last Updated : 2021-10-15
#Apache

Lets Encrypt 설정

Last Updated : 2021-09-15
#Lets_Encrypt

Alteon L4 초기 설정/로드밸런싱 설정

Last Updated : 2021-09-11