Apache 로그 위치와 LogFormat 읽는 법
Apache 로그 위치는 설치마다 다릅니다. Ubuntu 는 /var/log/apache2, Rocky 는 /var/log/httpd, Docker 는 docker logs 입니다. 지시어와 한 줄 읽는 법입니다.
Apache 의 로그 위치는 설치 방식에 따라 다릅니다. Ubuntu 패키지는 /var/log/apache2/, Rocky Linux 9 패키지는 /var/log/httpd/, 공식 Docker 이미지 httpd 는 파일 없이 표준 출력·표준 오류로 내보냅니다. 경로를 정하는 설정과 로그 한 줄 읽는 법을 순서대로 봅니다.
[1] 설치 방식별 기본 위치부터 확인합니다. 각 환경의 기본 설정에서 읽은 값입니다.
| 설치 방식 | 오류 로그 | 접속 로그 |
|---|---|---|
Ubuntu 24.04 apache2 | /var/log/apache2/error.log | /var/log/apache2/access.log, 공통 other_vhosts_access.log |
Rocky Linux 9 httpd | /var/log/httpd/error_log | /var/log/httpd/access_log |
Docker httpd:2.4 | 표준 오류(stderr) | 표준 출력(stdout) |
공식 문서에서 기본값이 있는 것은 ErrorLog(Unix 는 ServerRoot 아래 logs/error_log)뿐입니다. 접속 로그를 정하는 CustomLog 는 기본값이 없고, 위 경로는 각 배포가 설정 파일에 써 둔 값입니다. 직접 빌드했거나 위에 없는 패키지는 설정에 쓰인 CustomLog 를 직접 찾아야 합니다. 권한도 봅니다. Ubuntu 의 로그 파일은 root:adm 에 rw-r-----, Rocky 의 /var/log/httpd 는 drwx------ 이라, 일반 계정의 Permission denied 는 경로가 아니라 권한 문제입니다.
[2] 실제 경로는 설정에서 찾습니다. ErrorLog 가 오류 로그를, CustomLog 가 접속 로그의 위치와 형식 이름을 정하고, LogFormat 이 형식을 정의하며, LogLevel 이 오류 로그에 남길 심각도를 정합니다. 가상 호스트에 CustomLog 가 따로 있으면 그 호스트의 요청은 그 파일에 쌓입니다. Ubuntu 24.04 입니다.
# grep -RnE "^\s*(ErrorLog|LogLevel|CustomLog)" /etc/apache2/apache2.conf /etc/apache2/conf-enabled /etc/apache2/sites-enabled/etc/apache2/apache2.conf:134:ErrorLog ${APACHE_LOG_DIR}/error.log/etc/apache2/apache2.conf:143:LogLevel warn/etc/apache2/conf-enabled/other-vhosts-access-log.conf:2:CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined/etc/apache2/sites-enabled/000-default.conf:20: ErrorLog ${APACHE_LOG_DIR}/error.log/etc/apache2/sites-enabled/000-default.conf:21: CustomLog ${APACHE_LOG_DIR}/access.log combined# grep -n "APACHE_LOG_DIR" /etc/apache2/envvars23:export APACHE_LOG_DIR=/var/log/apache2$SUFFIX${APACHE_LOG_DIR} 는 envvars 에서 정해지므로 apache2 를 직접 실행하면 AH00111 ... is not defined 가 납니다. AH00111 해결을 봅니다. Rocky Linux 9 입니다. 상대 경로 logs/ 는 /etc/httpd/logs 심볼릭 링크를 거쳐 /var/log/httpd 로 갑니다.
# grep -nE "^\s*(ErrorLog|LogLevel|CustomLog)" /etc/httpd/conf/httpd.conf187:ErrorLog "logs/error_log"194:LogLevel warn222: CustomLog "logs/access_log" combined# ls -ld /etc/httpd/logslrwxrwxrwx 1 root root 19 Oct 22 21:04 /etc/httpd/logs -> ../../var/log/httpd[3] Docker httpd 이미지는 로그 파일을 만들지 않습니다. 설정이 두 로그를 표준 스트림(/proc/self/fd/2, /proc/self/fd/1)으로 보냅니다. 기본 설정 그대로 띄우고 요청을 두 번 보낸 뒤의 docker logs 입니다.
$ docker run --rm httpd:2.4 grep -nE '^\s*(ErrorLog|LogLevel|CustomLog)' /usr/local/apache2/conf/httpd.conf317:ErrorLog /proc/self/fd/2324:LogLevel warn346: CustomLog /proc/self/fd/1 common$ docker logs gblab-apache-log-location-format 2>&1AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this messageAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this message[Sun Nov 08 22:22:56.861433 2026] [mpm_event:notice] [pid 1:tid 1] AH00489: Apache/2.4.69 (Unix) configured -- resuming normal operations[Sun Nov 08 22:22:56.862064 2026] [core:notice] [pid 1:tid 1] AH00094: Command line: 'httpd -D FOREGROUND'203.0.113.5 - - [08/Nov/2026:22:22:58 +0000] "GET / HTTP/1.1" 200 191203.0.113.5 - - [08/Nov/2026:22:22:58 +0000] "GET /missing.html HTTP/1.1" 404 236오류 로그 줄과 접속 로그 줄이 한 흐름으로 섞여 나옵니다. 컨테이너 안 logs 폴더는 비어 있으니 파일을 cat 하지 말고 docker logs 를 씁니다. AH00558 은 ServerName 경고 해결에서 다룹니다.
[4] 접속 로그 한 줄은 LogFormat 자리표시자 순서대로 읽습니다. 아래는 combined 형식으로 파일에 남긴 로그이고(만드는 법은 [6]), 첫 요청에 Referer 헤더를 붙였습니다.
$ cat logs5/access_log203.0.113.5 - - [08/Nov/2026:22:23:02 +0000] "GET / HTTP/1.1" 200 191 "https://example.com/start" "curl/8.5.0"203.0.113.5 - - [08/Nov/2026:22:23:02 +0000] "GET /missing.html HTTP/1.1" 404 236 "-" "curl/8.5.0"왼쪽부터 %h 클라이언트 주소(앞에 프록시가 있으면 프록시), %l identd 신원, %u 인증 사용자(없으면 둘 다 -), %t 요청을 받은 시각, \"%r\" 요청 줄(메서드·경로·프로토콜), %>s 최종 상태 코드, %b 본문 바이트(헤더 제외, 없으면 -), 그 뒤 Referer 와 User-Agent 헤더입니다.
%>s 는 내부 리다이렉트를 거친 최종 상태이고 %s 는 처음 요청의 상태입니다. Ubuntu 의 combined 는 %b 대신 %O 를 씁니다.
# grep -n " combined$" /etc/apache2/apache2.conf213:LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined%b 는 응답 본문 크기, %O 는 헤더를 포함해 실제로 보낸 바이트(mod_logio 필요)라 서로 다른 값을 셉니다. 정상 완료된 응답이면 %O 가 헤더만큼 크고, 응답을 보내기 전에 중단되면 %O 는 0 이 될 수 있다고 문서가 설명합니다. 처리 시간(%D, 마이크로초)을 덧붙여 느린 요청을 세는 예는 MaxRequestWorkers 도달에 있습니다.
[5] 오류 로그 한 줄은 기본 ErrorLogFormat 모양입니다. 같은 컨테이너를 LogLevel info 로 올리고 없는 파일을 요청했습니다.
$ cat logs5/error_log[Sun Nov 08 22:23:00.180559 2026] [mpm_event:notice] [pid 1:tid 1] AH00489: Apache/2.4.69 (Unix) configured -- resuming normal operations[Sun Nov 08 22:23:00.180764 2026] [mpm_event:info] [pid 1:tid 1] AH00490: Server built: Nov 5 2026 07:15:08[Sun Nov 08 22:23:00.180781 2026] [core:notice] [pid 1:tid 1] AH00094: Command line: 'httpd -D FOREGROUND'[Sun Nov 08 22:23:02.210989 2026] [core:info] [pid 9:tid 22] [client 203.0.113.5:45184] AH00128: File does not exist: /usr/local/apache2/htdocs/missing.html앞에서부터 시각(마이크로초까지), [모듈:심각도], [pid:tid], 요청에 딸린 메시지면 [client 주소:포트], 그다음 AH 번호와 메시지입니다. 검색할 때는 AH 번호를 그대로 칩니다. 마지막 줄의 심각도가 info 입니다. 공식 문서에 따르면 404 의 File does not exist 는 2.4 에서 info 로 내려가 기본 LogLevel warn 에서는 오류 로그에 나오지 않습니다. 404 는 접속 로그의 404 로 찾고, 오류 로그에도 남기려면 문서가 안내하는 LogLevel warn core:info 를 씁니다.
[6] 위치를 파일로 바꾸는 방법과 주의입니다. 위 [4]·[5]의 컨테이너는 httpd.conf 의 ErrorLog·CustomLog 를 이렇게 바꿔 띄웠습니다.
ErrorLog "logs/error_log"CustomLog "logs/access_log" combined패키지 설치본은 문법을 검사한 뒤 반영합니다(Ubuntu 는 apache2ctl, Rocky 는 apachectl). graceful 은 진행 중인 요청을 끊지 않습니다.
# apache2ctl configtest# apache2ctl graceful파일 로그는 계속 커집니다. logrotate 설정 시험을 보고, 공식 문서가 권장으로 소개하는 CustomLog "|…/rotatelogs …" combined 방식도 있습니다. 로그 폴더는 서버를 시작하는 사용자 외에는 쓸 수 없게 둡니다. 공식 문서가 ErrorLog 에 단 보안 경고입니다.
[7] 로그에서 찾은 문구로 증상별 글을 고릅니다.
| 로그·증상 | 볼 글 |
|---|---|
AH00072 make_sock: could not bind | 포트 점유·없는 IP·권한 가르기 |
AH00558 ServerName 경고 | 전역 ServerName 넣기 |
AH00111 ${APACHE_RUN_DIR} is not defined | envvars 를 읽는 방법으로 실행 |
403 과 AH01630 | Require all granted |
403 과 AH01797 client denied | 남은 2.2 식 규칙 정리 |
AH00124 ... 10 internal redirects | 재작성 루프 끊기 |
Invalid command 'RewriteEngine' | mod_rewrite 켜기 |
Primary script unknown | php-fpm 경로 맞추기 |
AH00013 threaded MPM | prefork 또는 event + PHP-FPM |
프록시 503 과 AH01114 | 백엔드 주소·포트 맞추기 |
인증서·키 AH02565 | 공개키 해시 비교 |
느림, AH00484·AH00161 | MaxRequestWorkers 도달 |
패키지 판 번호와 보안 수정 반영 상태는 Apache 2.4.69 와 Ubuntu 24.04 상태에서 봅니다.
Apache 로그를 브라우저에서 바로 분석 ↗ — 아무것도 올라가지 않습니다.