調子良くドメイン分離した『にわ管』だが、問題は立て続ける。ひ〜〜(涙)
今回の問題です。
ログの中身が「common」のリテラルで埋め尽くされています。
何が起きているの?
ログのフォーマットをしているところは、ここだけな筈。
|
1 2 3 4 5 6 7 |
<IfModule log_config_module> LogFormat "%{%Y/%m/%d %T}t (%a)%u \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" my-combined <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "var/log/apache2/access_log" my-combined </IfModule> |
使っているのは、ここだけだと思う。
|
1 2 3 4 5 6 7 8 9 10 11 |
<VirtualHost *:80> ServerName niwakan.k-in.co.jp DocumentRoot "/Volumes/Works/Library/www/niwakan" <Directory "/Volumes/Works/Library/www/niwakan"> Options FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog "/opt/local/var/log/apache2/niwakan-error_log" CustomLog "/opt/local/var/log/apache2/niwakan-access_log" my-combined </VirtualHost> |
Geminiさんに聞いて、combinedから、専用の名称my-combinedに変更したところ。
結果はこうでした。
% tail niwakan-access_log
|
1 2 3 4 5 6 7 8 9 10 |
common common common common common common common common common common |
そこで今度は、Google AIさんにも参加して貰う。
頼るときには頼れる男。ってか頼りまくっているな(笑)
AIさんに言われて、コマンドを打ち込んでみる。
Includeされたファイルを確認してたのね。(知らんでただコピペしてたよ)
% apachectl -DDUMP_INCLUDES
|
1 2 3 4 5 6 7 |
Included configuration files: (*) /opt/local/etc/apache2/httpd.conf (495) /opt/local/etc/apache2/extra/httpd-multilang-errordoc.conf (510) /opt/local/etc/apache2/extra/httpd-vhosts.conf (511) /opt/local/etc/apache2/extra/httpd-vhosts-le-ssl.conf (16) /opt/local/etc/letsencrypt/options-ssl-apache.conf (528) /opt/local/etc/apache2/extra/httpd-ssl.conf |
そうして気が付いた。
VirtualHost絡みでもう一つファイルを読み込んでいたことを。
そう、自動更新の証明書発行で作られたものだね。(Googleのサイト証明書を取得してみる(2)参照)
こっちを見てみる。
% cat extra/httpd-vhosts-le-ssl.conf
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<IfModule mod_ssl.c> <VirtualHost *:443> ServerName niwakan.k-in.co.jp DocumentRoot "/Volumes/Works/Library/www/niwakan" <Directory "/Volumes/Works/Library/www/niwakan"> Options FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog "/opt/local/var/log/apache2/niwakan-error_log" CustomLog "/opt/local/var/log/apache2/niwakan-access_log" common SSLCertificateFile /opt/local/etc/letsencrypt/live/niwakan.k-in.co.jp/fullchain.pem SSLCertificateKeyFile /opt/local/etc/letsencrypt/live/niwakan.k-in.co.jp/privkey.pem Include /opt/local/etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule> |
ここにもniwakan-access_logがあった、それもcommon!
AIさんは、この中に LogFormat の my-combined を追加した後、common を my-combined に書き換えてみよう。とのアドバイス。
しかし手を抜きたいので、my-conbaind だけ書き換えてみる。
ダメでした〜〜。
% tail niwakan-access_log
|
1 2 3 4 5 6 7 8 9 10 |
common common common common common common my-conbined my-conbined my-conbined my-conbined |
なので、LogFormatも追加する。
うぉう、出てきたよぉ〜〜(喜)
% tail niwakan-access_log
|
1 2 3 4 5 6 7 8 9 10 |
my-conbined my-conbined my-conbined my-conbined my-conbined my-conbined my-conbined my-conbined 2026/09/30 11:14:09 (74.7.242.32)- "GET /wp-json/wp/v2/media/9253 HTTP/1.1" 200 4345 "https://niwakan.k-in.co.jp/archives/2022/09/9265/%e7%8b%90-2/" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.4; +https://openai.com/gptbot)" 2026/09/30 11:14:11 (192.168.0.35)- "POST /wp-cron.php?doing_wp_cron=1790734451.6878509521484375000000 HTTP/1.1" 200 - "-" "WordPress/7.1.2; https://niwakan.k-in.co.jp" |
何これ、一々全部に同じ定義入れないといけないの?
面倒臭ぇ〜(涙)
そこでAIさんのアドバイスが炸裂。
解決策:枠から「完全に外」へ出す
もし、httpd.conf の中で
やってみるかぁ。
先ずhttpd.confでは、LogFormat my-combined1行を外に出す。(中にも残してある)
|
1 2 |
LogFormat "%{%Y/%m/%d %T}t (%a)%u \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" my-combined <IfModule log_config_module> |
次に、extra/httpd-vhosts-le-ssl.conf、コメントにしてLogFormatを外す。(上手く行かなかった時の為の暫定処置)
|
1 |
# LogFormat "%{%Y/%m/%d %T}t (%a)%u \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" my-combined |
これでログに問題がなければ、完全消去可能。
で、結果は問題なさそう。
ログは出ていて、my-combinedのリテラルは出ていない模様。
ところで、こんな面倒なことになるのって可笑しくね。
楽するために纏めて定義させる筈が意味を成していない。
不満を言っても良いだろう? ね!

