为什么我只能用这种写法记录
LogEventInfo lei = new LogEventInfo();
lei.Level = LogLevel.Error;
lei.Properties["Account"] = "1";
lei.Properties["Date"] =DateTime.Now;
lei.Properties["ActionType"] = "1";
lei.Properties["Level"] = "1";
lei.Properties["Message"] = "1";
logger.Log(lei);
但是简单写法如:logger.Error("12344")虽然记录到了数据库,但是那条数据信息全为空;我的配置文件如下
<target name="database" xsi:type="Database">
<connectionString>${var:ConnectionStrings}</connectionString>
<commandText>
INSERT INTO lifeHome.sys_log (Account,ActionType,Level,Message,Date) Values(@Account,@ActionType,@Level,@Message,@Date)
</commandText>
<parameter name = "@Account" layout = "${event-context:item=Account}"/>
<parameter name = "@ActionType" layout = "${event-context:item=ActionType}"/>
<parameter name = "@Level" layout = "${event-context:item=Level}" />
<parameter name = "@Message" layout = "${event-context:item=Message}" />
<parameter name = "@Date" layout = "${event-context:item=Date}" />
<dbProvider>MySql.Data.MySqlClient.MySqlConnection,Mysql.Data</dbProvider>
</target>
</targets>
<rules>
<logger name="" writeTo="console" />
<logger name="" minlevel="Debug" writeTo="debugger" />
<logger name="" minlevel="Error" writeTo="error_file" />
<logger name="" level="Info" writeTo="info" />
<logger name="*" writeTo="database" />
</rules>