Sorry, you are not login!
VIP members can check the contents after login.
Click to login

  • TOP
  • Moblie
    All Prompt Messages

    Tradesns Foreign Trade Community
    Current page location: Home Page > Article > 如何启用Apache服务器记录日志
    Article author
    凯 李
    Concern
    Add friends
    Station news
    Selected articles of the author
    View more>
    如何启用Apache服务器记录日志
    Browse volume:213 | Reply:0 | Release time:2022-08-25 13:43:58

    如何启用Apache服务器记录日志?针对这个问题,今天小编总结这篇有关Apache服务器的文章,希望帮助更多想用Apache服务器记录日志的同学找到更加简单易行的办法。
    Apache服务器日志提供有助于检测服务器常见问题的详细信息。要记录网站的访问日志,必须启用mod_log_configmodule

    apache配置文件中有三个指令,即 -
    TransferLog:创建日志文件。
    LogFormat:指定自定义格式。
    CustomLog:创建和格式化日志文件。
    TransferLog指令在apache配置文件中可用,它根据设置参数轮转虚拟主机日志文件。
    VirtualHost www.example.com>

      ServerAdmin webmaster@yiibai.com
      DocumentRoot /usr/www/example/httpd/htdocs/
      ServerName www.example.com
      ServerAlias example.com www.example
      ErrorLog /usr/www/example/httpd/logs/error_log
      TransferLog /usr/www/example/httpd/logs/accesslog
      CustomLog /usr/www/example/httpd/logs/accesslog combined

    </VirtualHost>
    两种类型的Apache日志格式
    通用日志格式
    组合日志格式
    可以通过编辑apache配置文件来启用它们,即apache2.conf(Debian/ubuntu)httpd.conf(基于rpm的系统)文件。
    通用日志格式
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    CustomLog logs/access_log.log common
    Apache生成的通用日志内容示例如下
    [Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/test
    组合日志格式
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
    CustomLog log/access_log.log combined
    在上面格式中,
    %h是远程主机
    %l是由identd确定的用户的身份
    %uHTTP身份验证确定的用户名
    %t是服务器处理完请求的时间。
    %r是来自客户端的请求行(“GET/HTTP/1.0”)
    %> s是从服务器发送到客户端的状态代码(500,404)
    %b是客户端响应的大小(以字节为单位)Referer是链接到此URL的页面。
    用户代理是浏览器标识字符串。
    Apache生成的组合日志:

    199.180.11.91 - - [06/Mar/2019:04:22:58 +0100] "GET /robots.txt HTTP/1.1" 404 1228 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"

    云专线将网络解耦为核心网络、边缘网络、最后1km三部分。用户可根据使用情况,灵活配置核心网络、边缘网络、最后1km带宽。打破了传统带宽利用率不均衡问题,造成的高成本问题。

    自定义日志为服务器上的每个虚拟主机创建单独的日志文件。它需要在配置文件的虚拟主机部分中指定。

    可以看到下面提到的虚拟主机配置,生成的日志将为该虚拟主机自定义,并且将组合格式。

    Concern (0
    Commentary(0)
    Share
    Popular
    Relevant
    Baidu
    map