You are able to reading event log from .Net application.
We are using "EventLog" class of "System.Diagnostics" namespace.
There are three categories of event log available Application, Security and System.
Here is example for this.
In this example we take one combobox, this combobox contains three values "Application", "Security" and "System". You can select any one category to read event log and display it's result in grid.
ASPX Code :
C# Examples :
VB.net Examples :
Output :
(To view original image , click on image)
Here is an example of write or insert event log entry into windows event log. Click Here...
This type of C# Tips is very useful in day to day programming life.
Note : Give Us your valuable feedback in comments. Give your suggestions in this article so we can update our articles accordingly that.
We are using "EventLog" class of "System.Diagnostics" namespace.
There are three categories of event log available Application, Security and System.
Here is example for this.
In this example we take one combobox, this combobox contains three values "Application", "Security" and "System". You can select any one category to read event log and display it's result in grid.
ASPX Code :
<asp:DropDownList runat="server" ID="cboEventLog"> <asp:ListItem Text="Application" Value="Application"></asp:ListItem> <asp:ListItem Text="Security" Value="Security"></asp:ListItem> <asp:ListItem Text="System" Value="System"></asp:ListItem> </asp:DropDownList> <asp:Button runat="server" ID="btnGetEventLog" Text="Get Event Log" OnClick="btnGetEventLog_Click" /> <br /><br /> <asp:GridView ID="gvEventLog" runat="server" AllowPaging="true" PageSize="5" Width="100px" > </asp:GridView>
C# Examples :
EventLog objEL = new EventLog();
objEL.Source = cboEventLog.SelectedItem.Text;
gvEventLog.DataSource = objEL.Entries;
gvEventLog.DataBind();
VB.net Examples :
Dim objEL As New EventLog() objEL.Source = cboEventLog.SelectedItem.Text gvEventLog.DataSource = objEL.Entries gvEventLog.DataBind()
Output :
Here is an example of write or insert event log entry into windows event log. Click Here...
This type of C# Tips is very useful in day to day programming life.
Note : Give Us your valuable feedback in comments. Give your suggestions in this article so we can update our articles accordingly that.
No comments:
Post a Comment