Nginx中文文档
DocsHome
  • 贡献导引
  • 介绍
    • 安装 nginx
    • 从源码构建 nginx
    • 初学者指南
    • 管理指南
    • 控制 nginx
    • 连接处理方式
    • 设置哈希
    • 调试日志
    • 记录日志到 syslog
    • 配置文件度量单位
    • 命令行参数
    • Windows 下的 nginx
    • QUIC 和 HTTP/3 支持
    • nginx 如何处理请求
    • 服务器名称
    • 使用 nginx 作为 HTTP 负载均衡器
    • 配置 HTTPS 服务器
    • nginx 如何处理 TCP/UDP 会话
    • 关于 nginScript
  • 其他
    • Linux 软件包
  • How-To
    • 在 Win32 平台上使用 Visual C 构建 nginx
    • 设置 Amazon EC2 的 Nginx Plus 环境
    • 使用 DTrace pid 提供程序调试 nginx
    • 转换重写规则
    • WebSocket 代理
  • 开发
    • 贡献指南
    • 开发指南
  • 模块参考
  • 核心功能
    • HTTP
      • ngx_http_core_module
      • ngx_http_access_module
      • ngx_http_addition_module
      • ngx_http_api_module
      • ngx_http_auth_basic_module
      • ngx_http_auth_jwt_module
      • ngx_http_auth_request_module
      • ngx_http_autoindex_module
      • ngx_http_browser_module
      • ngx_http_charset_module
      • ngx_http_dav_module
      • ngx_http_empty_gif_module
      • ngx_http_f4f_module
      • ngx_http_fastcgi_module
      • ngx_http_flv_module
      • ngx_http_geo_module
      • ngx_http_geoip_module
      • ngx_http_grpc_module
      • ngx_http_gunzip_module
      • ngx_http_gzip_module
      • ngx_http_gzip_static_module
      • ngx_http_headers_module
      • ngx_http_hls_module
      • ngx_http_image_filter_module
      • ngx_http_index_module
      • ngx_http_js_module
      • ngx_http_keyval_module
      • ngx_http_limit_conn_module
      • ngx_http_limit_req_module
      • ngx_http_log_module
      • ngx_http_map_module
      • ngx_http_memcached_module
      • ngx_http_mirror_module
      • ngx_http_mp4_module
      • ngx_http_perl_module
      • ngx_http_proxy_module
      • ngx_http_random_index_module
      • ngx_http_realip_module
      • ngx_http_referer_module
      • ngx_http_rewrite_module
      • ngx_http_scgi_module
      • ngx_http_secure_link_module
      • ngx_http_session_log_module
      • ngx_http_slice_module
      • ngx_http_spdy_module(过时)
      • ngx_http_split_clients_module
      • ngx_http_ssi_module
      • ngx_http_ssl_module
      • ngx_http_status_module(过时)
      • ngx_http_stub_status_module
      • ngx_http_sub_module
      • ngx_http_upstream_module
      • ngx_http_upstream_conf_module
      • ngx_http_upstream_hc_module
      • ngx_http_userid_module
      • ngx_http_uwsgi_module
      • ngx_http_v2_module
      • ngx_http_xslt_module
    • Mail
      • ngx_mail_core_module
      • ngx_mail_auth_http_module
      • ngx_mail_proxy_module
      • ngx_mail_ssl_module
      • ngx_mail_imap_module
      • ngx_mail_pop3_module
      • ngx_mail_smtp_module
    • Stream
      • ngx_stream_core_module
      • ngx_stream_access_module
      • ngx_stream_geo_module
      • ngx_stream_geoip_module
      • ngx_stream_js_module
      • ngx_stream_keyval_module
      • ngx_stream_limit_conn_module
      • ngx_stream_log_module
      • ngx_stream_map_module
      • ngx_stream_proxy_module
      • ngx_stream_realip_module
      • ngx_stream_return_module
      • ngx_stream_split_clients_module
      • ngx_stream_ssl_module
      • ngx_stream_ssl_preread_module
      • ngx_stream_upstream_module
      • ngx_stream_upstream_hc_module
      • ngx_stream_zone_sync_module
    • 其他
      • ngx_google_perftools_module
由 GitBook 提供支持
在本页
  • 示例配置
  • 指令
  • session_log
  • session_log_format
  • session_log_zone
  • 内嵌变量
  • 原文档
  1. 核心功能
  2. HTTP

ngx_http_session_log_module

上一页ngx_http_secure_link_module下一页ngx_http_slice_module

最后更新于5年前

ngx_http_session_log_module 模块启用会话日志(多个 HTTP 请求的聚合),而不是单个 HTTP 请求。

该模块作为我们的一部分提供。

示例配置

以下配置根据请求客户端的地址和 User-Agent 请求头字段设置会话日志并将请求映射到会话:

session_log_zone /path/to/log format=combined
                    zone=one:1m timeout=30s
                    md5=$binary_remote_addr$http_user_agent;

location /media/ {
    session_log one;
}

指令

session_log

-

说明

语法

session_log name | off;

默认

session_log off;

上下文

http、server、location

允许使用指定的会话日志。特殊值 off 取消从先前配置级别继承的所有 session_log 指令。

session_log_format

-

说明

语法

session_log_format name string ...;

默认

session_log_format combined "...";

上下文

http

指定日志的输出格式。$body_bytes_sent 变量的值聚合在会话的所有请求中。可用于记录的所有其他变量的值对应于会话中的第一个请求。

session_log_zone

-

说明

语法

session_log_zone path zone=name:size [format=format] [timeout=time] [id=id] [md5=md5];

默认

——

上下文

http

设置日志文件的路径,并配置用于存储当前活动会话的共享内存区域。

只要会话中的最后一个请求经过的时间不超过指定的 timeout(默认为 30 秒),会话就被视为活动状态。会话不再处于活动状态后将被写入日志。

id 参数标识请求映射到的会话。id 参数设置为 MD5 哈希的十六进制形式(例如,使用变量从 cookie 中获取)。如果未指定此参数或不是有效的 MD5 哈希,则 nginx 将根据 md5 参数的值计算 MD5 哈希,并使用此哈希创建新会话。id 和 md5 参数都可以包含变量。

内嵌变量

ngx_http_session_log_module 模块支持两个内嵌变量:

  • $session_log_id

    当前会话 ID

  • $session_log_binary_id

    二进制形式的当前会话 ID(16字节)。

原文档

format 参数设置 指令配置的自定义会话日志格式。如果未指定 format,则使用预定义的 combined格式。

http://nginx.org/en/docs/http/ngx_http_session_log_module.html
商业订阅
示例配置
指令
session_log
session_log_format
session_log_zone
内嵌变量
session_log_format