2. 웹 서버 로깅의 목적
오류 발생시 문제의 원인을 찾기 위해
사이트의 접근 통계를 위해
3. 일반적인 HTTP 로깅 필드
HTTP 메서드, HTTP 버전, 요청 받은 리소스의 URL,
응답 상태 코드, 요청과 응답 메시지 크기,
트랜잭션이 일어나 시간, Referer와 User-Agent 헤더
4. 표준화된 로그 포멧을 사용하자
웹 로깅에 표준화된 로그 포멧을 사용할 경우, 이와 호환이 되는
이미 만들어진 툴들을 이용할 수 있다.(통계, 에러 분석 등등)
5. 일반 로그 포멧(Common Log)
필드 설명
remotehost 요청한 컴퓨터의 호스트 명 혹은 IP주소
username ident 검색을 수행했다면, 인증된 요청자의 사용자 이름
auth-username 인증을 수행했다면, 인증된 요청자의 이름
timestamp 요청 날짜와 시간
request-line HTTP 요청 라인
response-code 응답 상태 코드
response-size 응답 엔터티의 Content-Length
209.1.32.44 - - [03/Oct/1999:14:16:00 -0400] "GET / HTTP/1.0" 200 1024
http-guide.com - dg [03/Oct/1999:14:16:32 -0400] "GET / HTTP/1.0" 200 477
http-guide.com - dg [03/Oct/1999:14:16:32 -0400] "GET /foo HTTP/1.0" 404 0
6. 혼합 로그 포멧(Combined Log)
필드 설명
Referer 어느 사이트에서 링크를 따라 왔는지
User-Agent HTTP 클라이언트 애플리케이션 정보
209.1.32.44 - - [03/Oct/1999:14:16:00 -0400] "GET / HTTP/1.0" 200 1024
"http://www.joes-hardware.com/" "5.0: Mozilla/4.0 (compatible;
MSIE 5.0; Windows 98)"
일반 로그 포멧에 2개의 추가 필드 사용
7. 넷스케이프 확장 로그 포멧
필드 설명
proxy-response-code 프락시를 거칠 경우, 프락시로의 HTTP 응답 코드
proxy-response-size 프락시를 거칠 경우, 서버가 프락시에 전달하는 응답의 엔터티 크기
client-request-size 클라이언트가 프락시로 보내는 요청의 엔터티 크기
proxy-request-size 프락시를 거칠 경우, 프락시가 서버로 보내는 요청의 엔터티 크기
client-request-hdr-size 클라이언트 요청 헤더의 크기
proxy-request-hdr-size 프락시를 거칠 경우, 프락시가 서버로 전송하는 요청 헤더의 크기
server-response-hdr-size 서버 응답 헤더의 크기
proxy-timestamp 프락시를 거칠 경우, 요청과 응답이 프락시를 통해 오가는 총 시간
209.1.32.44 - - [03/Oct/1999:14:16:00-0400] "GET / HTTP/1.0" 200
1024 200 1024 0 0 215 260 279 254 3
프락시나 웹 캐시와 같은 여러 환경을 지원하기 위해 일반 로그 포멧을 확장
8. 넷스케이프 확장 2 로그 포멧
필드 설명
route 프락시가 클라이언트로의 응답을 만드는데 사용한 경로
client-finish-status-code 클라이언트의 요청의 종료 상태 코드(클라이언트->프락시) FIN, INTR …
proxy-finish-status-code 프락시의 종료 상태 코드(서버 -> 프락시) FIN, INTR …
cache-result-code 캐시 결과 코드, 캐시가 요청에 어떻게 응답했는지를 기술
209.1.32.44 - - [03/Oct/1999:14:16:00-0400] "GET / HTTP/1.0" 200
1024 200 1024 0 0 215 260 279 254 3 DIRECT FIN FIN WRITTEN
확장 로그 포멧에서 프락시와 웹 캐시와 관련한 더 많은 정보를 제공
9. 적중 계량하기
서버는 접근 통계를 위해 상세 로그를 저장(ex: 광고 서비스)
만약, 중간에 캐시가 있다면??
해당 컨텐츠가 얼마나 조회가 되었는지를 서버가 알수 없음
적중 계량(Hit Metering): 캐시가 정기적으로 캐시 접근 통계를 서버에 보고
10. Figure 21-1 shows an example of Hit Metering in action. The first part of the transac-
tion is just a normal HTTP transaction between a client and proxy cache, but in the
proxy request, note the insertion of the Meter header and the response from the
server. Here, the proxy is informing the server that it is capable of doing Hit Meter-
ing, and the server in turn is asking the proxy to report its hit counts.
The request completes as it normally would, from the client’s perspective, and the
proxy begins tracking hits to that resource on behalf of the server. Later, the proxy
tries to revalidate the resource with the server. The proxy embeds the metered infor-
mation it has been tracking in the conditional request to the server.
Figure 21-1. Hit Metering example
Requestmessage
Client
GET http://joes-hardware.com/ HTTP/1.1
Host: www.joes-hardware.com
Accept: *
www.joes-hardware.com
GET / HTTP/1.1
Host: www.joes-hardware.com
Meter: will-report-and-limit
Connection: Meter
Responsemessage
HTTP/1.1 200 OK
Date: Fri, 06 Dec 1996 18:44:29 GMT
Content-length: 3152
Content-type: text/html
Connection: Meter
ETag: "v1.27"
Meter: do-report
[...]
Proxy
Client
Later, thecacherevalidatesthe
responseandatthesametime
reportsthehitcount
www.joes-hardware.com
GET / HTTP/1.1
Host: www.joes-hardware.com
Meter: 12/4
If-None-Match: "v1.27"
Connection: Meter
HTTP/1.1 304 Not Modified
[...]
Responsesenttoclient,cached,and
usedforsubsequentrequests
Proxy
Proxy
HTTP/1.1 200 OK
Date: Fri, 06 Dec 1996 18:44:29 GMT
Content-length: 3152
Content-type: text/html
[...]
Meter 헤더 사용
프락시는 리소스에 대한 재
검사 요청시 해당 리소스가
조회된 횟수를 서버에 전송
11. 개인 정보 보호
로깅은 관리자와 개발자에게 유용한 도구지만 로깅을 당하는 사용자들
의 인지나 허가가 없으면 로깅이 사생할 침해가 된다는 것을 유념