dbi encoding problem

Tags:

#1 amylonas

I am having this weird encoding problem. I am exporting utf8 characters into a local mysql table. when i export from nxlog into a file the characters seem ok. when i switch to dbi export its jiberish. i tried debugging the queries from mysql into a log to check if the characters arrive in the db intact and the characters seem fine there. collation in mysql is utf8. any ideas?

#2 adm Nxlog ✓
#1 amylonas
I am having this weird encoding problem. I am exporting utf8 characters into a local mysql table. when i export from nxlog into a file the characters seem ok. when i switch to dbi export its jiberish. i tried debugging the queries from mysql into a log to check if the characters arrive in the db intact and the characters seem fine there. collation in mysql is utf8. any ideas?

For MySQL the encoding is handled by the client driver usually. The libdbi mysql driver has an encoding option so the following should work (although untested):

<Output dbi>
    Module	om_dbi
    SQL         INSERT INTO log (facility, severity, hostname, timestamp, application, message) \
                VALUES ($SyslogFacility, $SyslogSeverity, $Hostname, '$EventTime', $SourceName, $Message)
    Driver	mysql
    Option	host 127.0.0.1
    Option	username dbuser
    Option	password secret
    Option      dbname logdb 
    Option      encoding utf-8
</Output>