2
4

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編)

Last updated at Posted at 2018-02-07

アクセスやらエラーを調査する際に使える(かもしれない)コマンド群です。
今回はApache編ですが、もちろん他ログでも使用できます。

■特定IPが記されている行だけ抽出
zgrep "192.168.XXX.XXX" ssl_request_log*

■特定IPを複数指定する場合
zgrep "192.168.XXX.XXX|192.168.XXX.YYY" ssl_request_log*

■特定IPかつPOST以外の接続方法でアクセスした行を抽出したい場合
zgrep "192.168.XXX.XXX" ssl_request_log* | grep -v "POST"

■特定IPのアクセス状況をリストアップする場合
zgrep "192.168.XXX.XXX" ssl_request_log* > ./list.txt

■上司に"先月の10~11時台のアクセス状況を日毎に出して~"と言われた場合
zgrep "Jan/2018:10|Jan/2018:11" ssl_request_log*

zgrepを使用することで、logrotateで圧縮されたログからも解凍する事なく抽出できるので便利です。

2
4
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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?