LoginSignup
2
3

More than 5 years have passed since last update.

「tail -f」ワイルドカードで複数指定すると捗る!!

Last updated at Posted at 2015-09-06

前置き

以前に、開発時にログを見るならtailよりもless!! - Qiita という記事を書いて、less はいいよということで紹介しましたが、、、
ワイルドカードが使える tail コマンドは、まだまだ捨てられませんでした。。w

以下の様なログがあるとして。

  • /var/log/nginx/hoge_access.log
  • /var/log/nginx/fuga_access.log

tailコマンドでワイルドカード指定するといい感じでまとめてログをtailしてくれます。。。

tail -f /var/log/nginx/*_access.log

または以下のようにするとすべてのログを対象にも出来る
tail -f /var/log/nginx/*.log

ワイルドカードを使え場ということで、当たり前っちゃ当たり前ですが、
railsresque など複数のログをまとめて出力しつつテストするときはだいぶ便利です。

具体的には以下の様な出力となります。

==> hoge_access.log <==
127.0.0.1 - - [22/Jul/2015:05:44:07 +0000] "GET /index.php HTTP/1.1" 200 67794 "-" "curl/7.40.0" "-" "-"
127.0.0.1 - - [22/Jul/2015:05:44:08 +0000] "GET /index.php HTTP/1.1" 200 67794 "-" "curl/7.40.0" "-" "-"

==> fuga_access.log <==
127.0.0.1 - - [22/Jul/2015:05:44:15 +0000] "GET /index.php HTTP/1.1" 200 67777 "-" "curl/7.40.0" "-" "-"

==> hoge_access.log <==
??.??.??.?? - - [22/Jul/2015:05:44:21 +0000] "GET /healthcheck.html HTTP/1.1" 404 336 "-" "ELB-HealthChecker/1.0" "-" "-"
??.??.??.?? - - [22/Jul/2015:05:44:25 +0000] "GET /healthcheck.html HTTP/1.1" 404 336 "-" "ELB-HealthChecker/1.0" "-" "-"

==> hoge_access.log <== の部分で各ログファイルの境目となっています。

tail はまだまだ捨てられないでした。。

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