Skip to content

Instantly share code, notes, and snippets.

@chensoren
Created April 12, 2025 02:02
Show Gist options
  • Save chensoren/1c1009dd2119142bf423b1aeef52616c to your computer and use it in GitHub Desktop.
Save chensoren/1c1009dd2119142bf423b1aeef52616c to your computer and use it in GitHub Desktop.
只查看某一个controller对应的action日志
#!/bin/bash
# 设置日志文件路径
LOG_FILE="/project/current/log/production.log"
# 使用 tail -f 实时监控日志,并用 awk 过滤出相关日志
tail -10f $LOG_FILE | awk '
# 当找到包含 SimilaritiesController#index 的行时,记录其请求 ID
/Processing by SimilaritiesController#index/ {
match($0, /\[(.*?)\]/)
request_id = substr($0, RSTART+1, RLENGTH-2)
print
next
}
# 如果行包含已记录的请求 ID,则打印该行
{
if (request_id != "" && $0 ~ request_id) {
print
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment