悬赏园豆:5
[已解决问题]
解决于 2008-05-30 10:40
<P>今天要用log4net记录用户操作。<BR>遇到了如题的问题。我想用log4net把级别为Info的信息保存到oracle数据库,其它的都保存到文件<BR>请教配置文件该如何写</P>
<P>试了很久了,还是没有保存到数据库 下面是我的配置,<BR><log4net><BR> <root><BR> <level value="INFO" /><BR> <appender-ref ref="AdoNetAppender_Oracle" /><BR> </root><BR> <!--<root><BR> <level value="ERROR"/><BR> <appender-ref ref="RollingFileAppender"/><BR> </root>--> <BR> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"><BR> <file value="log\\log2.txt"/><BR> <appendToFile value="true"/><BR> <maxSizeRollBackups value="10"/><BR> <maximumFileSize value="2000KB"/><BR> <rollingStyle value="Size"/><BR> <staticLogFileName value="true"/><BR> <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/><BR> <layout type="log4net.Layout.PatternLayout"><BR> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/><BR> </layout><BR> </appender></P>
<P> <appender name="AdoNetAppender_Oracle" type="log4net.Appender.AdoNetAppender"><BR> <connectionType value="System.Data.OracleClient.OracleConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /><BR> <connectionString value="Password=111;User ID=111;Data Source=tempo" /><BR> <bufferSize value="128" /><BR> <commandText value="INSERT INTO Log(msg) VALUES (:msg)" /><BR> <parameter><BR> <parameterName value=":msg" /><BR> <dbType value="String" /><BR> <size value="2000" /><BR> <layout type="log4net.Layout.PatternLayout"><BR> <conversionPattern value="%message" /><BR> </layout><BR> </parameter><BR> </appender><BR></log4net></P>