简体   繁体   中英

Log4net adoNetAppender dosent insert logging event in bulk

Is any way to override SendBuffer method in AdoNetAppender to bulk insert logs in database? in below this link in SendBuffer method log4net write logs in database by iteration over loggingevent and insert each of them in separated query, I wanna insert all logs in a query, i think this approach increase performance.

You can make a class like:

public class MyAdoNetAppender : AdoNetAppender
{
    override protected void SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
    {
        (... implementation goes here)
    }
}

You can use the class in config like (MyDll is your dll name, and make sure you have the namespace correct):

 <appender name="A1" type="MyAdoNetAppender,MyDll">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM