WaYdotNET Web Blogs

Il blog di Carlo Bertini e qualcosa di .NET
posts - 57, comments - 408, trackbacks - 1041

Sending the LINQ To SQL log to log4net

Interessante codice x poter salvare i log di Linq to Sql con log4net:

"

DataContext Log Property can be used to print generated SQL query or command in the console window as shown below:

db.Log = Console.Out;

If you want to print the SQL query in DebugView or VS Output window you may use DebugWriter class(by Kris Vandermotten) .The usage of the class is pretty simple ...

db.Log = new DebugWriter(); 

I wrote a small class that help you redirect DataContext messages to log4net .I've changed the DebugWriter and call it Log4NetWriter . The usage is still simple

db.Log = new Log4NetWriter(this.GetType()); 

As result you get formatted log4net messages that can be send to any log4net appender ."

 

Fonte (con codice):

http://devintelligence.com/blogs/netadventures/archive/2008/01/26/sending-the-linq-to-sql-log-to-log4net.aspx

Technorati Tags: ,

Print | posted on lunedì 11 febbraio 2008 16.25 |

Feedback

Gravatar

# Shitting in toilet.

Shitting.
19/06/2008 13.44 | Shitting girls.
Gravatar

# Wild party girls.

Girls gone wild.
20/11/2008 11.32 | Girls gone wild clips.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 6 and 5 and type the answer here:

Powered by: