Proxy log analyzer can parse various web proxy logĀ formats and display it in a spreadsheet form. Using this software, Administrator can monitor frequent sites visited by each internet user. The software can maintain list of IPs and its corresponding owner. Each column on the spreadsheet can be sorted so the administrator can view the proxy log by IP, owner, datetime and website visited.
AUTHOR
foxtrot0911
PLATFORM
Framework: Microsoft .NET Framework 3.5
IDE: Visual C# 2008 Express Edition
BEST PRACTICE FOR
Reading files using StreamReader
Use of LINQ to query from Collection
SAMPLE SCREENSHOTS
SAMPLE CODES/TECHNIQUES
Below is the code for reading the log file. It uses StreamReader namespace to parse the file line by line.
private bool ReadLog(string LogPath)
{
bool lreturn = true;FileInfo[] d;
DirectoryInfo dir = new DirectoryInfo(@LogPath);
if (dir.Exists)
{
d = dir.GetFiles(Settings.Default.LOG_EXTENSION);foreach (FileInfo f in d)
{
try
{
WriteLog(“Reading file ” + f.Name + “…”);
StreamReader tmpstream = File.OpenText(@f.FullName);
string strraw = tmpstream.ReadLine();
while (strraw != null)
{
string[] strinfo1 = strraw.Split(new string[] { ” – - ” }, StringSplitOptions.None);
string[] strcmd = ReadRaw(strinfo1[1]).Split(new char[] { ‘|’ });
WriteLog(“Inserting to database the reading from ” + strinfo1[0] + “…”);
if (SaveToDB(strinfo1[0], strcmd))
{
WriteLog(“Successfully inserted.”, Color.Blue);
}
strraw = tmpstream.ReadLine();}
tmpstream.Close();
WriteLog(“Moving file to ” + @Settings.Default.FINISH_FOLDER);
f.MoveTo(@Settings.Default.FINISH_FOLDER + “\\” + f.Name);
}
catch (Exception ex)
{
lreturn = false;
WriteLog(“Error while reading file. ” + ex.Message, Color.Red);
}
}
}
else
{
WriteLog(“Directory does not exist. “, Color.Red);
}
return lreturn;
}
Query from Class collection using LINQ
clsAccountables accs = new clsAccountables();
var linqaccs = (from clsAccountable o in accs
where o.Accountable.Trim().ToLower() != “test”
select o.Accountable).Distinct();
cboAccountable.Items.Clear();
cboAccountable.Items.Add(“Unknown”);
foreach (var linqacc in linqaccs)
{
cboAccountable.Items.Add(linqacc.ToString());
}
DOWNLOAD URL
You can download the full source code on the following location:
Filed under: C# , C#, LINQ, Proxy, Proxy Log, Proxy Log Analyzer, Proxy Log Reader, StreamReader, Web Proxy Log

