Nlog 手动配置
var config = new NLog.Config.LoggingConfiguration( );
var logfile = new NLog.Targets.DatabaseTarget( ) { };
logfile.CommandText = "insert into MyLog ([CreateDate], [Origin], [LogLevel], [Message], [StackTrace]) values (@createDate, @origin, @logLevel, @message, @stackTrace);";
logfile.CommandType = System.Data.CommandType.Text;
logfile.ConnectionString = "";
logfile.Name="dblog";
logfile.Parameters.Add( new DatabaseParameterInfo( "@createDate", "${longdate}" ) );
logfile.DBProvider = "MySql.Data.MySqlClient";//System.Data.SqlClient
config.LoggingRules.Add( new NLog.Config.LoggingRule( "*", NLog.LogLevel.Debug, logfile ) );
NLog.LogManager.Configuration = config;
loggerFactory.AddNLog();