Click here to Skip to main content
14,921,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ,
my project is to implement logging module to the sql database using visual studio 2010 (c#). am using logging application block with tracelistener . i want to read logs in the event log and then logging these logs to the database .... i don`t know how to read my logs and how to connect them to the logging application block .... any help pleas .

with my regard

1 solution

This article defines a simple way to read logs and then you can write your own code to write in the database. Look for the function - btnReadLog_Click :[^]
Hope it helps....
Badour alsamaraie 30-Sep-11 13:37pm
thanks prdshulka
but when am use the code for reading log entries an error is appear :

Warning 1 'System.Diagnostics.EventLogEntry.EventID' is obsolete: '"This property has been deprecated. Please use System.Diagnostics.EventLogEntry.InstanceId instead.

that i cant understand..... the second thing i want to read all entries not last two , how can i modify the for loop to meet my request???

if i want to write each entry to the database do you think that the procedure to write to the database will be inside the for loop ???

sorry or annoying you but i really wont toy help....

with my regard
Pradeep Shukla 30-Sep-11 14:11pm
use the new InstanceId as the earlier property is obsolete..nothing to bother.
change the for loop like this:
for ( i = 0; i>= LastLogToShow - 1; i++) and read through all the logs...
Badour alsamaraie 30-Sep-11 18:56pm
from my reading to different articles i found that there must be a connection between my created database and my log ... so am used logging application block. i must configure it to log to the database.
would you hep me how to config it? i dont know how to make there read logs as input to it ???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900