Tomcat日志訪問統計可通過以下方式實現:
cat /path/to/tomcat/logs/localhost_access_log.*.txt | wc -l
。cat /path/to/tomcat/logs/localhost_access_log.*.txt | awk '{print $1}' | sort | uniq -c | sort -nr
。cat /path/to/tomcat/logs/localhost_access_log.*.txt | awk '{print $8}' | sort | uniq -c | sort -nr
。cat /path/to/tomcat/logs/localhost_access_log.*.txt | awk '{print $7}' | sort | uniq -c | sort -nr | head -1
。awk
提取關鍵指標。conf/server.xml
中調整AccessLogValve
格式,確保記錄所需字段(如IP、URL、狀態碼)。選擇工具時,可根據數據規模、實時性需求和技術棧決定,小型項目可用命令行或GoAccess,大型項目推薦ELK Stack。