Created
April 12, 2025 02:02
-
-
Save chensoren/1c1009dd2119142bf423b1aeef52616c to your computer and use it in GitHub Desktop.
只查看某一个controller对应的action日志
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) | |
next | |
} | |
# 如果行包含已记录的请求 ID,则打印该行 | |
{ | |
if (request_id != "" && $0 ~ request_id) { | |
} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment