Alex Rivera | Logout

What is your strategy to write logs in your software to deal with possible HUGE amount of log messages?

Asked 2012-03-06T11:41:46.030
8

Thanks for your time and sorry for this long message!

My work environment

Linux C/C++(but I'm new to Linux platform)

My question in brief

In the software I'm working on we write a LOT of log messages to local files which make the file size grow fast and finally use up all the disk space(ouch!). We want these log messages for trouble-shooting purpose, especially after the software is released to the customer site. I believe it's of course unacceptable to take up all the disk space of the customer's computer, but I have no good idea how to handle this. So I'm wondering if somebody has any good idea here. More info goes below.

What I am NOT asking

1). I'm NOT asking for a recommended C++ log library. We wrote a logger ourselves.

2). I'm NOT asking about what details(such as time stamp, thread ID, function name, etc) should be written in a log message. Some suggestions can be found here.

What I have done in my software

I separate the log messages into 3 categories:

  • SYSTEM: Only log the important steps in my software. Example: an outer invocation to the interface method of my software. The idea behind is from these messages we could see what is generally happening in the software. There aren't many such messages.

  • ERROR: Only log the error situations, such as an ID is not found. There usually aren't many such messages.

  • INFO: Log the detailed steps running inside my software. For example, when an interface method is called, a SYSTEM log message is written as mentioned above, and the entire calling routine into the internal modules within the interface method will be

Edit
Report

1 Answer

3

I would

a) Make the level of detail in the log messages configurable at run time. b) Create a new log file for each day. You can then get cron to either compress them and/or delete them or perhaps transfer to off-ling storage.

answered 2012-03-06T11:45:47.627

Your Answer