Easy way to extract the log to a text file

7 posts · Closed

thetechfirm
12 May 2018

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.

Andrew SoftPerfect
12 May 2018

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:

  1. Download the SQLite command line shell and extract sqlite3.exe.
  2. 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.

thetechfirm
13 May 2018

Wow. Looks like what I was looking for. I will give it try and let you know how I made out.
Thanks

thetechfirm
14 May 2018

You were 100% correct, it wasn't that bad and i was able to get the logs very easily.
Thanks again!

Ann SoftPerfect
14 May 2018

Glad to hear that everything went well and you are happy with the result :)

thetechfirm
15 May 2018

Can I use SQLite to clear the log? The client was asking if we could clear the logs weekly.

Andrew SoftPerfect
15 May 2018

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')"
This topic is closed. It has had no new posts for over a year, so the software versions it talks about may be out of date. Start a new topic in Bandwidth Manager if you have a similar question.