Friday, April 29, 2016

Log4Net not logging in SQL Server

I was using Log4Net for one of my projects. The idea is to log everything into SQL. For some reason it was not logging. Finally after checking all these items, I was able to make it work. Hope this checklist will help you as well.
 
1. Copy the SQL config files from this example link.
 
2. Check the SQL Database connection string in the config file. Make sure that the Database Name is correct.
 
3. Check the SQL command in the config file. Make sure the table name is right.
 
4. Check the SQL Table in SQL and make sure it has the "Identity Column." Usually for the Id column the "Identity" should be enabled to true.
 
5. Turn on the SQL Server Profiler and examine the command coming into the SQL server.
 
6. If nothing is coming into SQL, then probably the Log4Net configuration file is not loaded. Try to load the configuration file programmatically.
 
Good Luck.
 
Cheers
Adam
 

No comments:

Post a Comment

All Blogs so far ...