I added Serilog to my app and the Console Sink works great. I then added the MySQL sink to the configuration. My settings are:
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.MySQL" ],
"MinimumLevel": "Debug",
"WriteTo": [
{ "Name": "Console" },
{
"Name": "MySQL",
"Args": {
"connectionString": "server=<server>;uid=<username>;pwd=<password>;database=logging_database",
"tableName": "logging",
"storeTimestampInUtc": true
}
}
],
}
I'm able to access the database with phpMyAdmin, so I know it's working.
The error that I get is:
Error: 0 : Unable to connect to any of the specified MySQL hosts.
Has anyone seen this or know how to fix it????
The issue appears to be with name resolution. The MySql server I was connecting to was being hosted on another server. I threw together a quick installation on a spare machine and just used IP address and it worked fine. So, on a hunch, I tried using the IP address instead of the name and it worked.
I also had to add SslMode=none into the connection string. I discovered that the sink doesn't gracefully handle connections that don't support SSL.