Personal tools
You are here: Home PC Linux logwatchの文字化け
Document Actions

logwatchの文字化け

by かわうぃん last modified 2008-01-20 08:54

毎日送られるlogの日本語文字化け修正 (Sambaからのlog) logwatch-7.3-5

Logwatchから送られるメールのヘッダーを見ると次のようになっています。

MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="iso-8859-1"

そのため、日本語を含むログ(Samba等)は文字化けします。
 --------------------- samba Begin ------------------------ 


Connections Denied:
lib/util_sock.c:get_peer_addr(1232) getpeername failed. Error was ÄÌ¿®Ã¼ÅÀ¤¬Àܳ
¤µ¤ì¤Æ¤¤¤Þ¤»¤ó 0.0.0.0 : 20 Time(s)
lib/util_sock.c:get_peer_addr(1232) getpeername failed. Error was ÄÌ¿®Ã¼ÅÀ¤¬Àܳ
¤µ¤ì¤Æ¤¤¤Þ¤»¤ó 0.0.0.0 : 20 Time(s)

**Unmatched Entries**
lib/util_sock.c:get_peer_addr(1232) getpeername failed. Error was ÄÌ¿®Ã¼ÅÀ¤¬Àܳ¤µ¤ì
¤Æ¤¤¤Þ¤»¤ó : 33 Time(s)


Logwatchを修正します。

# vi /usr/sbin/logwatch内の ”iso-8859-1”の箇所を"iso-2022-jp"へ修正

if ( $outtype_html ) {
#  $out_mime .= "Content-Type: text/html; charset=\"iso-8859-1\"\n\n";
   $out_mime .= "Content-Type: text/html; charset=\"iso-2022-jp\"\n\n";
         } else {
#  $out_mime .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n\n";
   $out_mime .= "Content-Type: text/html; charset=\"iso-2022-jp\"\n\n";
         }

修正後のログ

 --------------------- samba Begin ------------------------ 


Connections Denied:
lib/util_sock.c:get_peer_addr(1232) getpeername failed. Error was 通信端点が接続
されていません 0.0.0.0 : 21 Time(s)
lib/util_sock.c:get_peer_addr(1232) getpeername failed. Error was 通信端点が接続
されていません 0.0.0.0 : 21 Time(s)

**Unmatched Entries**
lib/util_sock.c:get_peer_addr(1232) getpeername failed. Error was 通信端点が接続され
ていません : 31 Time(s)



Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: