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?

AskedJune 28, 2015 - 10:26pm

Answer (1)

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
    Option	username dbuser
    Option	password secret
    Option      dbname logdb 
    Option      encoding utf-8

Comments (1)

  • amylonas's picture

    thank you for your response. I tried the utf8 encoding option in nxlog as well as in my.cnf and mysql debug log confirms it with "Query     SET NAMES utf8". The mysql log continues to show proper utf8 text but still no luck in the database. I am running out of ideas. Would it be possible to run query via async_exec? I am giving it a shot now but it keeps saying "no such file or directory"