c# - Shutting down a single log4net instance -
i have multiple appenders in log4net configuration, 1 logging file, , other using stored procedure. i'm able see logging file, sql data show after click "stop site", see image below:
so i've come conclusion may have 'shutdown' instance doing following: log4net.logmanager.getlogger("searchparamslogger").logger.repository.shutdown();
but in doing so, seems shut down other logger. how can shut down 1 logger?
i have following logger
blocks:
<logger name="searchparamslogger"> <level value="debug" /> <appender-ref ref="logsearchparams" /> </logger> <logger name="filelogger"> <level value="debug" /> <appender-ref ref="logfile" /> </logger>
i have following appenders in .config:
<appender name="logsearchparams" type="log4net.appender.adonetappender"> <buffersize value="100" /> <connectiontype value="system.data.sqlclient.sqlconnection, system.data, version=1.0.3300.0, culture=neutral, publickeytoken=b77a5c561934e089" /> <connectionstring value="data source=myserver\sqlexpresspc;initial catalog=mydatabase;integrated security=false;persist security info=true;user id=dbuser;password=mypassword" /> <commandtext value="insertimannrllog" /> <commandtype value="storedprocedure" /> <parameter> <parametername value="@username"/> <dbtype value="string" /> <size value="255" /> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%property{uname}" /> </layout> </parameter> <parameter> <parametername value="@objectid" /> <dbtype value="string" /> <size value="4000" /> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%message" /> </layout> </parameter> <parameter> <parametername value="@deletespan" /> <dbtype value="int32" /> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%property{deletespan}" /> </layout> </parameter> <parameter> <parametername value="@loglevel" /> <dbtype value="string" /> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%level" /> </layout> </parameter> </appender> <appender name="logfile" type="log4net.appender.fileappender"> <file value="application.log"/> <appendtofile value="true"/> <layout type="log4net.layout.patternlayout"> <header value="logging start 
"/> <footer value="logging end 
"/> <conversionpattern value="%date | [%thread] %-5level %logger: %message%newline"/> </layout> </appender>
you can configure number of messages dbappender buffer before flushing them db.
your <buffersize value="100" />
default example found here, lower , should see messages more often, can immediate logging db value 1 (or lower)
Comments
Post a Comment