• Grey Twitter Icon
  • Grey Facebook Icon
  • Grey LinkedIn Icon
  • Grey Google+ Icon

© 2016 - 2019 All rights reserved. PigeonSQL.com | Filip Holub

Log4net logs to Database.

December 11, 2016

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:

 <log4net>

   ...

</log4net>

 

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.

 

 

 

 

 

 

 

Please reload

RECENT POST
Please reload

  • Facebook Social Icon
  • Google+ Social Icon
  • LinkedIn Social Icon
  • Twitter Social Icon