Tecnologia e Educação

geek, curioso, curitibano, vivendo a base de água e café. #

Apache’s logs to Mysql

Posted on

Recently I had to work with some data generated by the apache. It is not a easy task to do because in general this log files are very huge

In order to make it easier I built a little python script that converts the apaches’logs to mysql database.

By putting the logs at a database it is going to be very easy and fast to search what you want to. You can do it just by doing selects.

To use this scripts you need to configure the database (line 17)

con = MySQLdb.connect('<address>', '<user>', '<password>')
con.select_db('<database name>')

After that you need to fill the path of the log files (line 26)

serverLogs = ('log-file-1.log','log-file-2.log')

I put this scripts at the GitHub here you can download it you will also find the sql file to be used to create the database table.

Comentários