Hi all...
Once again... In trouble....
Please guide me... How to build event logs in any asp.net c# website ??
Requirement -
1. If a user opens a portal, then the system must capture the page name (index.aspx), the user name, and current time. - Done.
2. If user clicks on any button (say btn_Save, btn_Search), then system much capture the pagename, username, button-id, button-text that was clicked, and time.
In short... How to create such event logs for asp.net website / portals ?
Currently there are 20 web pages in the portal.
Do I need to use System.Diagnostics namespace??
--------------------------------------
Other Point -
I have recently faced an incident.
I had uploaded my published files on the iis server.(Remote Desktop Connection)
The system was running smoothly.
But... One other person from other team entered the server and changed the physical path of my portal.
By this, I got many complaints from the users that the site is not working.
-------
Is there any way in which we can find out who enters the server and make such changes ??
-----
Is there any way in which we can capture the username/windows name and find the activities done on server ??
--
Please guide.
Thank you all in advance...
Loading
Riddhi ValechaPosted Apr 6, 2015, 8:01 AM
I need CPU time..
Gowtham RajamanickamPosted Apr 6, 2015, 4:31 AM
Riddhi ValechaPosted Apr 5, 2015, 5:11 AM
Also..let me know how to get the memory usage ??
Riddhi ValechaPosted Mar 29, 2015, 5:23 AM
I cannot share the code.
Can you post code-lines here ??
1 more thing... I am working on Visual Studio 2012 and SQL Server 2008.
Jitendra KumarPosted Mar 28, 2015, 9:04 AM
Kindly share your code for more understanding.
Riddhi ValechaPosted Mar 28, 2015, 7:43 AM
System.Diagnostic namespace will not give CPU usage.....
I need CPU time, CPU Resources, etc that are used when running a website...
Jitendra KumarPosted Mar 27, 2015, 1:35 AM
For CPU Performance you use
PerformanceCounter Class
See Links :-
https://msdn.microsoft.com/en-us/library/system.diagnostics.performancecounter.aspx
http://stackoverflow.com/questions/4679962/what-is-the-correct-performance-counter-to-get-cpu-and-memory-usage-of-a-process
Riddhi ValechaPosted Mar 26, 2015, 9:24 AM
System.DIagonstics namespace has Stopwatch...
This calculates time in milliseconds.
But, What to do if I want to calculate machine time, CPU Time, get resources used by CPU, time taken by each resource, etc.
In Short, How to calculate CPU Time ???
Jitendra KumarPosted Mar 25, 2015, 7:19 AM
Riddhi ValechaPosted Mar 25, 2015, 3:24 AM
PLease let me know how to calculate time taken for code in button_click to execute ??
button_click()
{
//10 lines of c# Code
}
--
How many seconds/ milli seconds are required to execute these 10 lines.
----
There are 8 methods in my application, in which there are more parameters(more than 9).
The portal was developed in 2012 (don't know by whom).
I know, that more parameters in a method is not a good programming practice.
I want to know -
1. Time taken to execute a method with 1 parameter.
2. Time taken to execute a method with 9 and more parameters.
---
Difference between less and more number of parameters in a method...
Please Guide... Thanks in advance..
Jitendra KumarPosted Mar 22, 2015, 8:09 AM
In Function you write code for insert data in database like this :-
public static void CreatErrorLog(string Pagename, string ctrlname, string ctrlid, string ipaddress, string txt)
{
MySqlConnection conn = new
MySqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
MySqlCommand cmd = new MySqlCommand("Insert into student (pagename,ctrlname,ctrlid,ipaddress, txt)
values (pagename,ctrlname,ctrlid,ipaddress, txt)", conn);
}
And Now call this function with value.
Get Page page Name -- Path.GetFileNameWithoutExtension(Request.Path);
Button Name in get in btnclick event
For IP Address See links :-
http://stackoverflow.com/questions/19285957/how-to-get-public-ip-address-of-a-user-in-c-sharp
http://www.aspsnippets.com/Articles/How-to-get-IP-Address-of-Visitors-Machine-in-ASP.Net.aspx
Like CreatErrorLog(Path.GetFileNameWithoutExtension(Request.Path), buttonname, id, ip, txt);
If any problem or query plz revert me.
Riddhi ValechaPosted Mar 22, 2015, 7:47 AM
I need all these things in database (sql server).
Example -
-----------
How do I achieve this ??
Jitendra KumarPosted Mar 21, 2015, 9:57 AM
Create log file using Function like this :-
public static void CreatErrorLog(string strMsg)
{
string strLogFilePath = null;
if (System.IO.Directory.Exists("d:\\ErrorLog") == false)
{
System.IO.DirectoryInfo dirELogs = default(System.IO.DirectoryInfo);
dirELogs = System.IO.Directory.CreateDirectory("d:\\ErrorLog");
}
strLogFilePath = "d:\\ErrorLog\\ErrorLog_";
FileStream fs1 = default(FileStream);
StreamWriter sw = default(StreamWriter);
DataSet dsFile = new DataSet();
try
{
if (System.IO.File.Exists(strLogFilePath) == false)
{
fs1 = new FileStream(strLogFilePath, FileMode.Create);
sw = new StreamWriter(fs1);
sw.WriteLine(msg.Trim());
sw.WriteLine("-----------------------");
sw.Close();
fs1.Close();
}
else
{
fs1 = new FileStream(strLogFilePath, FileMode.Append, FileAccess.Write);
sw = new StreamWriter(fs1);
sw.WriteLine(msg.Trim());
sw.WriteLine("-----------------------");
sw.Close();
fs1.Close();
}
}
}
And Now call this function with value whatever you want to show in log.
Like CreatErrorLog("hello")
CreatErrorLog(Page.Name + btn.Name)
If any problem or query plz revert me.