2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

シンプル: Apache ログから特定の日と特定の IP のログだけを抽出する

Posted at

自分用メモなんですが、他に上手い人、良い方法があったら教えてください

とあるサーバーの、Apache ログの解析をしようと思ったんですが、Apache ログが日付分割されておらず、1GBぐらいの巨大ファイルになっていたので、日付で絞り込んでから、IP アドレスで絞り込んで、ログを抽出しました。

書式

grep "【日付】" 【ログファイル保存先】 | grep "【自分のIP】" > 【保存先】.log
  • Apache の設定によって日付フォーマットが代わります
  • ログの保存先も vhosts 設定とかしてたら違うファイル名
  • IP アドレス以外でも User-Agent とか指定して可能
  • grep をパイプして複数絞込も可能

grep "31/Mar/2017" /var/log/httpd/access_log | grep "128.0.0.1" > httpd_log_20170331_c5j.log
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?