logging - Logger does not work auto automatically when I use SQL Server -
i want write log texts sql server, when u use logger.debug()
method, works well.
but if project throws exception, writes nothing sql server. when use log4net.config
write logs txt, works well.
i not know whether log4net.config
wrong! can me?
<appender name="adonetappender_sqlserver" type="log4net.appender.adonetappender"> <buffersize value="1" /> <connectiontype value="system.data.sqlclient.sqlconnection, system.data, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/> <connectionstring value="data source=.; initial catalog=myproject; user id=sa; password=123456;" /> <commandtext value="insert dbo.log ([date],[thread],[level],[logger],[message],[exception]) values (@log_date, @thread, @log_level, @logger, @message, @exception)" /> <parameter> <parametername value="@log_date" /> <dbtype value="datetime" /> <layout type="log4net.layout.rawtimestamplayout" /> </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="error" /> <appender-ref ref="adonetappender_sqlserver" /> </root>
i expect ambient transaction exists, ado database connection enlisting with. when exception occurs ambient transaction rolled back, includes log entries inserted database.
try adding enlist=false
connection string in appender config.
Comments
Post a Comment