log4net配置文件如下:
<!--插入数据库--> <appender name="AdoNetAppender_MySql" type="log4net.Appender.ADONetAppender"> <bufferSize value="1"/> <connectionType value="MySql.Data.MySqlClient.MySqlConnection, MySql.Data" /> <!--<connectionType value="MySql.Data.MySqlClient.MySqlConnection, MySql.Data, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />--> <connectionString value="server=服务器地址;user id=用户名;pwd=密码;port=端口号;pooling=True;database=数据库" providerName="MySql.Data.MySqlClient;" /> <commandText value="INSERT INTO DB_Log(log_datetime,log_thread,log_level,log_logger,log_message,log_exception) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)"/> <parameter> <parameterName value="@log_date"/> <dbType value="DateTime"/> <layout type="log4net.Layout.RawTimeStampLayout"/><!--记录日志的时间--> <!--<layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss}" />--> </parameter> <parameter> <parameterName value="@thread"/> <dbType value="String"/> <size value="255"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%thread"/><!--记录日志时的线程号--> </layout> </parameter> <parameter> <parameterName value="@log_level"/> <dbType value="String"/> <size value="50"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%level"/><!--日志级别--> </layout> </parameter> <parameter> <parameterName value="@logger"/> <dbType value="String"/> <size value="255"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%logger"/><!--哪个记录器存储的该日志--> </layout> </parameter> <parameter> <parameterName value="@message"/> <dbType value="String"/> <size value="4000"/> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%message"/><!--日志信息--> </layout> </parameter> <parameter> <parameterName value="@exception"/> <dbType value="String"/> <size value="2000"/> <layout type="log4net.Layout.ExceptionLayout"/><!--异常信息--> </parameter> </appender> <root> <level value="ALL"/> <appender-ref ref="AdoNetAppender_MySql"/> </root>
连接字符串有没有问题?
没问题,其他也看不出啥问题