티스토리 뷰

728x90
반응형

 포스팅은 apache LogFormat 설정 관련 자료입니다.


apache httpd.conf에 설정가능한 LogFormat에 대한 가이드입니다.


$APACHE_HOME/conf/httpd.conf


...

...

<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 "%l %h %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>

...

...



$APACHE_HOME/conf/extra/httpd-vhost.conf or $APACHE_HOME/conf/extra/httpd-ssl.conf


...

...

<VirtualHost *:80>

    ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot "/usr/share/nrson/apache/htdocs"

    ServerName 192.168.2.31

    #ServerAlias www.nrson.com

    ErrorLog "logs/my-error_log"

    #LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common

    #CustomLog "logs/my-access_log" vhost_common

    CustomLog "logs/my-access_log" common

</VirtualHost>

...

...



위와 같이 CustomLog & LogFormat은 매칭으로 이루어져 있습니다.

LogFormat "log 포멧" nickname

CustomLog "log 경로" nickname


위와 같은 형태로 nickname 기준으로 LogFormat을 결정합니다.

마찬가지로 vhost & ssl에 설정된 CustomLog에서도 직접 LogFormat을 설정할수도 있으며, httpd.conf에 설정된 LogFormat의 nickname을 불러올 수도 있습니다.

728x90
반응형