Is there a way to export the contents of access.log to excel spreadsheet so as to manipulate the data from there?
3 Answers
The squid native log format is :
time elapsed remotehost code/status bytes method URL rfc931 peerstatus/peerhost type
In the fact, you can develop a simple parser using awk or maybe with perl or python, ... and delimit the data with a delimiter of your choice to get a CSV file. Somethink like this:
awk '{ print $1","$2","$3","$4","$5","$6","$7","$8","$9","10 }' /var/log/squid/access.logFor more information, please find here a small squid log viewer using python. http://github.com/mezgani/sqview
Easy enough with Perl, which has modules for working with Excel, but wouldn't a database be a more appropriate tool? Excel really seems like the wrong tool for this job. Sort of like using a lawnmower to pick flowers. Sure it will work but there are better ways.
Yeah, Excel can read CSV files, so your best bet would be to alter the log format such that it's comma separated (or perhaps some other delineation token). You can then open your CSV-formatted Squid log using Excel.
See: http://wiki.squid-cache.org/Features/LogFormat
Alternatively, if you don't care to alter the format, you can toss a script together to reformat to include the fields you need.