In this post you will find an answer to his question:
"How to turn on logging to database with Log4net?"
I have dealt will logging to database several times, because my colleagues often solve erros in applications and they have to look at the Log file. In the Config file of Applications is default turn on logging to log files on the server, where is not access for Users, but only for Admin. I had to devise some ways logging, where will have access our development department.
After a while googling, I found that it is possible logging save to database.
So, I created database "LogDB" and there I created the following table:
Then I had to edit the Config File! We inserted code between these attributes:
As you can see here:
You must edit the name of SQL Server and the name of Database. In my case it is "LogDB" in "Connectionstring" - data source=Your Instace;initial catalog=LogDB;
In the end insert the string <appender-ref ref="AdoNetAppender" />
The result looks like this:
The last thing we need to do is to set permission (Write) in the table, for the user who is running the Application. In my case, when I have an Apps running in IIS and It has its own Application Pool where the service account, is that service account must have table permission se to write.
And then I can grant permissions for the logs tale to read and It will became accessible for my colleagues from the Development daparture.