Apache | Log Files | Log File Locations (CustomLog, ErrorLog)

The locations of the access log and error log are defined in httpd.conf. First, look at the access log.

Access log: CustomLog

The location of the access log file is specified with CustomLog. Search for CustomLog in httpd.conf, and you should find content like the following.

<IfModule log_config_module>
    #
    # 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

    <IfModule logio_module>
      # 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
    </IfModule>

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

The CustomLog format for specifying an access log file is as follows.

CustomLog log-file-location log-format-name

The log file location is specified relative to the ServerRoot location. For ServerRoot, see “Server Location Directory (ServerRoot).”

The log format name specifies which log definition, defined by LogFormat, should be recorded. The text at the end of LogFormat is the format name. The details of the format are explained on another page.

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

Therefore, the LogFormat name on the first line is combined, and the LogFormat name on the second line is common.

The access log enabled by default is defined as follows.

 CustomLog "logs/access.log" common

This setting uses access.log as the log file name and common as the log format.

Error log: ErrorLog

The location of the error log file is specified with ErrorLog. Search for ErrorLog in httpd.conf, and you should find content like the following.

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error.log"

The error log file location is also specified relative to the ServerRoot location.

Checking log files

The access log and error log are text files, so they can be opened with a text editor.

C:\apache\Apache24\logs>dir
 C 드라이브의 볼륨에는 이름이 없습니다.
 볼륨 일련 번호: XXXX-XXXX

 C:\apache\Apache24\logs 디렉터리

2019-12-05  오후 11:29    <DIR>          .
2019-12-05  오후 11:29    <DIR>          ..
2019-12-05  오후 11:25            17,108 access.log
2019-12-05  오후 11:29            60,733 error.log
2019-12-05  오후 11:29                 7 httpd.pid
2019-08-09  오후 11:50             3,146 install.log
               4개 파일              80,994 바이트
               2개 디렉터리  450,580,013,056 바이트 남음

C:\apache\Apache24\logs>

access.log

127.0.0.1 - - [03/Dec/2019:01:21:23 +0900] "GET /referer.html HTTP/1.1" 304 -
127.0.0.1 - - [03/Dec/2019:01:21:23 +0900] "GET /img/devkuma.jpg HTTP/1.1" 403 199
::1 - - [03/Dec/2019:01:21:32 +0900] "GET /referer.html HTTP/1.1" 304 -
::1 - - [03/Dec/2019:01:21:32 +0900] "GET /img/devkuma.jpg HTTP/1.1" 304 -
127.0.0.1 - - [03/Dec/2019:01:21:51 +0900] "GET /img/devkuma.jpg HTTP/1.1" 200 5168
::1 - - [03/Dec/2019:01:22:43 +0900] "-" 408 -
::1 - - [03/Dec/2019:01:22:43 +0900] "-" 408 -
127.0.0.1 - - [03/Dec/2019:01:22:51 +0900] "-" 408 -
127.0.0.1 - - [03/Dec/2019:01:53:07 +0900] "GET /admin/admin.page HTTP/1.1" 401 381
127.0.0.1 - - [03/Dec/2019:01:53:34 +0900] "GET /admin/admin.html HTTP/1.1" 401 381
127.0.0.1 - - [03/Dec/2019:01:54:12 +0900] "GET / HTTP/1.1" 200 99

error.log

[Thu Dec 05 23:27:14.834393 2019] [mpm_winnt:notice] [pid 5788:tid 580] AH00364: Child: All worker threads have exited.
[Thu Dec 05 23:27:14.852887 2019] [mpm_winnt:notice] [pid 11848:tid 576] AH00430: Parent: Child process 5788 exited successfully.
[Thu Dec 05 23:29:01.662578 2019] [mpm_winnt:notice] [pid 10168:tid 668] AH00455: Apache/2.4.41 (Win64) PHP/7.4.0 configured -- resuming normal operations
[Thu Dec 05 23:29:01.662578 2019] [mpm_winnt:notice] [pid 10168:tid 668] AH00456: Apache Lounge VS16 Server built: Aug  9 2019 16:46:32
[Thu Dec 05 23:29:01.662578 2019] [core:notice] [pid 10168:tid 668] AH00094: Command line: 'httpd.exe -d C:/apache/Apache24'
[Thu Dec 05 23:29:01.665949 2019] [mpm_winnt:notice] [pid 10168:tid 668] AH00418: Parent: Created child process 7372
[Thu Dec 05 23:29:02.063030 2019] [mpm_winnt:notice] [pid 7372:tid 664] AH00354: Child: Starting 64 worker threads.

Details of the recorded format and settings such as the error level recorded in the error log are explained on the following pages.