Easy way to extract the log to a text file
7 posts · Closed
Is there an easy way to extract the log to a text file?
I read about the database file, but working with that sounds a bit daunting. We have a monitoring page and it would be helpful if I could post the log file to see who exceeded their quota, system errors, etc.
There isn't really anything difficult in working with the database and you can extract data from it with simple SQL statements.
For example, to convert the list of events to a text file, try the following:
- Download the SQLite command line shell and extract sqlite3.exe.
- In a command prompt execute something like this:
sqlite3 -csv "C:\ProgramData\SoftPerfect\Bandwidth Manager\Bandwidth Manager.DB" "SELECT * FROM EVENT ORDER BY ID" > somefile.txt
This will open the database file, select all events from the EVENT table and save them to somefile.txt comma-separated.
Another way to do it is to connect to the database directly from your web-page (depending on what scripting language is available) without using an intermediate text file. You can use the SQLiteSpy tool to explore the database.
Wow. Looks like what I was looking for. I will give it try and let you know how I made out.
Thanks
You were 100% correct, it wasn't that bad and i was able to get the logs very easily.
Thanks again!
Glad to hear that everything went well and you are happy with the result :)
Can I use SQLite to clear the log? The client was asking if we could clear the logs weekly.
Absolutely, just run it like this to clear the log:
sqlite3 "C:\ProgramData\SoftPerfect\Bandwidth Manager\Bandwidth Manager.DB" "DELETE FROM EVENT"
Alternatively, if you only want to remove log records older than a week:
sqlite3 "C:\ProgramData\SoftPerfect\Bandwidth Manager\Bandwidth Manager.DB" "DELETE FROM EVENT WHERE MESSAGE_TIME < datetime('now', '-7 days', 'localtime')"