Log4net is an open source .net library to log output to a variety of sources like console, SMTP, Plain text, Database etc. Log4net is a port of the popular log4J library used in Java. Log4net developed by Apache Foundation. Full details of log4net can be found at its project homepage. Its powerful tool to logging application output to different targets. Log4net provide different types of provider to save logging into plain text, database etc. Log4net enable logging at runtime without modifying the application binary. Its provide high speed of logging.
2. How to save log4net log into database
How to use log4net in .net
What is Log4net
Log4netis an opensource .netlibrarytolog outputto a varietyof sources like console,SMTP,Plain
text,Database etc. Log4netis a port of the popularlog4JlibraryusedinJava. Log4net developedby
Apache Foundation. Full detailsof log4netcanbe foundat itsprojecthomepage. Itspowerful tool to
loggingapplication outputtodifferenttargets.Log4netprovide differenttypesof providertosave
loggingintoplaintext,database etc. Log4netenable loggingatruntime withoutmodifyingthe
applicationbinary. Itsprovide highspeedof logging.
log4netisthe notionof hierarchical loggers log4netisdesigned forspeedandflexibility
Home page of log4net- http://logging.apache.org/log4net/index.html
Followingisstepstosave log4netlogintodatabase
1. Add Log4net.dll into your project
2. Add log4net into Global.asax.cs
3. Register log4net in configSections
4. Use log4net configuration in web.config sections
5. Create a database and table to save log into Sql server. I am creating
"Log4NetTest" database and "AppLog" table to save log into database
6. Use following Log4net settings in your controller, where you want use
log4net
3. Step 1 . Add Log4net.dll into your project
Addlog4net"log4net.dll"libraryintoyourproject. youcandownloadlog4netbinaryfromfollowing URL
https://logging.apache.org/log4net/download_log4net.cgi
4. Its containsdifferentbinfile fordifferent.netversion.Youcanadd log4net.dll accordingtoyour
requirementand.netversion.
Or
Package Manager- You can install log4netviapackage manager
Go to Tools>>NuGetPackage Manager >> Package Manager
thenrun
PM> Install-Package log4net