検索

カレンダー

2010年10月
« 9月   11月 »
 123
45678910
11121314151617
18192021222324
25262728293031

広告

ブログランキング・にほんブログ村へ
にほんブログ村

東電電力供給情報

カテゴリー

最近のコメント

リンク

squidのログファイルをapache形式にする

投稿者:yasu 更新日時:2010年10月7日 12時14分42秒
カテゴリCentOS, Squid

以前CentOS5にインストールしたsquidですが、squidのログファイルっていつアクセスしたかわからないですよね?
これをapache形式にして時間がわかるようにしたいと思います。
初期状態のログはこんな感じ
↓↓↓↓↓
1285922644.977 4 127.0.0.1 TCP_MISS/503 1379 POST http://safebrowsing.clients.google.com/safebrowsing/downloads? - NONE/- text/html

これが設定を変更するとこんな感じになります。
↓↓↓↓↓
127.0.0.1 - - [01/Oct/2010:17:44:37 +0900] "GET http://www.sh.turbolinux.com/support/image_support/side_caption_4c_4_f2.gif HTTP/1.1" 200 1118 TCP_MISS:DIRECT

squidの設定ファイルを編集します

[root@centos ~]# vi /etc/squid/squid.conf

~ 中略 ~

# TAG: access_log
# These files log client request activities. Has a line every HTTP or
# ICP request. The format is:
# access_log [ [acl acl ...]]
# access_log none [acl acl ...]]
#
# Will log to the specified file using the specified format (which
# must be defined in a logformat directive) those entries which match
# ALL the acl's specified (which must be defined in acl clauses).
# If no acl is specified, all requests will be logged to this file.
#
# To disable logging of a request use the filepath "none", in which case
# a logformat name should not be specified.
#
# To log the request via syslog specify a filepath of "syslog":
#
# access_log syslog[:facility.priority] [format [acl1 [acl2 ....]]]
# where facility could be any of:
# authpriv, daemon, local0 .. local7 or user.
#
# And priority could be any of:
# err, warning, notice, info, debug.
#
# Note: 2.6.STABLE14 and earlier only supports a slightly different
# and undocumented format with all uppercase LOG_FACILITY|LOG_PRIORITY
#access_log /var/log/squid/access.log squid ←先頭に#を追記してコメント化
access_log /var/log/squid/access.log auto ←追記

~ 中略 ~

# TAG: emulate_httpd_log on|off
# The Cache can emulate the log file format which many 'httpd'
# programs use. To disable/enable this emulation, set
# emulate_httpd_log to 'off' or 'on'. The default
# is to use the native log format since it includes useful
# information Squid-specific log analyzers use.
#
#Default:
emulate_httpd_log on ←追記

ファイルを保存してviエディタを終了します

squidのサービスを再起動して設定を反映します

[root@centos ~]# /etc/rc.d/init.d/squid restart
squid を停止中: ................ [ OK ]
init_cache_dir /var/spool/squid/coss... squid を起動中: . [ OK ]

ログファイルの確認

[root@centos ~]# cat /var/log/squid/access.log

ログファイルを確認してapache形式の表示になっていれば設定完了です。

“squidのログファイルをapache形式にする”にコメントはありません

コメントする