Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know a lot of logging libraries but didn't test a lot of them. (GoogleLog, Pantheios, the coming boost::log library...)

In games, especially in remote multiplayer and multithreaded games, logging is vital to debugging, even if you remove all logs in the end.

Let's say I'm making a PC game (not console) that needs logs (multiplayer and multithreaded and/or multiprocess) and I have good reasons for looking for a library for logging (like, I don't have time or I'm not confident in my ability to write one correctly for my case).

Assuming that I need :

  1. performance
  2. ease of use (allow streaming or formating or something like that)
  3. reliable (don't leak or crash!)
  4. cross-platform (at least Windows, MacOSX, Linux/Ubuntu)

Wich logging library would you recommand?

Currently, I think that boost::log is the most flexible one (you can even log to remotely!), but have not good performance update: is for high performance, but isn't released yet. Pantheios is often cited but I don't have comparison points on performance and usage. I've used my own lib for a long time but I know it don't manage multithreading so it's a big problem, even if it's fast enough. Google Log seems interesting, I just need to test it but if you already have compared those libs and more, your advice might be of good use.

Games are often performance demanding while complex to debug so it would be good to know logging libraries that, in our specific case, have clear advantages.

share|improve this question
One requirement that matters that you didn't mention is what you intend to use the logs for. The requirements for logging, say, debug messages, metrics for designers, character state for customer support, and credit card transactions, are different. In general you trade off performance, ease of use for programmers, ease / speed of offline parsing, and durability depending on the situation. – user744 Feb 17 '11 at 15:45
That's right, but I was assuming that a "complete" logging solution would allow the users to setup different kind of logs like you describe. If you find this precision important in the question, please be my guest and add it to the question. – Klaim Feb 18 '11 at 12:39
up vote 8 down vote accepted

log using socket (any socket wrapper can suffice) + web browser websocket => most versatile, unobtrusive logging tool possible, will gain hours of debugging and avoid eye-sore.

  • asyncrhonous (speed as it defers all the job on the browser)
  • formatted (color, size etc..)
  • reliable (sockets...)
  • cross-platform (browser)

Now, the bonus:

  • dynamic filtering very easily done (using javascript regex if needed)
  • with log history, memory and compare (HTML5 spec on the "in-browser" database)
  • Easy way to make some graph of any data (using SVG, or canvas or anything) like memory, memory fragmentation, etc...
  • easy way to make some 2D graph of any data (kd-tree subdivision ? potential field ? or even just a variable value variation ? etc...)
  • allows distant logging (using the browser other computer)
  • using html5 in browser storage, you can store log session parameteres (current log filters, etc.. and even notes on each)
  • very easy to create bug report or link trac tickets just with a click
  • ability to rewind logging easily, with a timeline gui

and many more task outside of logging:

  • allows profiler info (graphs...)
  • can even serve as console (send command from browser) or even with quick GUI using some HTML or even flash ui
  • image diff in the browser (send image using socket, and compare in browser using canvas image pixel capabilities)
  • etc...

(nearly all of the above can be done using flash sockets, save the database capabilities)

Now I know it seems a bit long to set up the thing. But it really is a gain of time on long project, with hard debugging situation (such as in games.) It's the most powerful thing I used since debuggers...

Note 1: the only downside => double-check side effect when debugging game networking code (impact on socket buffer size, latency, bandwidth, etc...)

Note 2: some broswer deactivated by default websocket due to security reason, check about:config things to be sure it's enabled.

share|improve this answer
Correct me if I'm wrong, but this only suggests where to direct logging output to, no? A real logging library would also allow filtering at compile-time (which is crucial if performance is an issue), formatting, and provide an easy-to-use syntax for creating log messages. – sbi Feb 17 '11 at 16:32
@sbi It's a global on or off thing on the application side. "Browser log client" does the filtering, syntax, but it always get all the log. It's radical, but it's based on the experience that during dev, you should always log everything so that you can catch/reproduce easily any bugs you stumble upon. If you have to optimize, it's browser side again : Using socket you're not bound to log using string, you can directly log binary data (Id + floats), which is bold faster than any other string based log lib...(matching Id to string browser side...) – Tuan Kuranes Feb 19 '11 at 6:23
While I can see that this is very practical, it's really just a logger's backend (what templog calls a "log sink", IIRC). Performance is one of the requirements listed. I have found that I need to add log statements to a piece of code while debugging it, but once it's up and running this piece of code would be too talkative and drown whatever I'm working on then in its noise, and would also cost too much performance. So I want to be able to tone up and down the log level on whole pieces of code with changing a few lines of code. That's what a log lib's middle layer does for you. – sbi Feb 19 '11 at 21:19
@sbi: may require benchmarks, but there's chance that the best logging library, even at the lowest logging level, still costs you more than a binary logger that logs everything. There is not even a single "binary to char" CPU Cycle wasted... So it's really more feature AND more performance. – Tuan Kuranes Feb 20 '11 at 6:18
Before we decided to actually use templog, we made some tests. If logging is turned off for the severity, origin, or whatnot of a specific log message, and if the compiler is able to find out that there are no side effects in evaluating the parameters, then VC is indeed able to optimize a full-blown log statement into nothingness. And when it comes to speed, you won't beat code that isn't there to be executed in the first place. – sbi Feb 20 '11 at 9:55

When it comes to performance, I've found templog pretty much unbeaten. It uses expression templates to defer evaluation of logging statements until it's established that the information will be logged at all. Since you can also partly turn off logging (depending on severity, origin, and targeted audience of a log message), some of these logging statement can be eliminated to zero code by the compiler for release builds. (I have actually seen this happen with VC.)

There wasn't much done to the library recently, and others on SO have found the trunk lacking in some regards, but in a company I used to work for we have found the guy quite responsive, and one of my then cow-workers even got commit access and added some code to it, so you might find it worth a shot.

To enumerate your requirements:


Best I've found. Especially its ability to exclude log messages at compile-time and have the compiler completely eliminate those was very appealing.

ease of use (allow streaming or formating or something like that)

There's the classical horrible compiler error messages of templates-meta stuff when you do something wrong, but when it comes to ease of use, this

TEMPLOG_LOG(my_logger,sev_error,aud_support) << "logged in as " << user_name;

is hard to beat.
However, you might have to create your own log sinks (that's where the log messages go), as the few pre-packaged ones (stderr, file, Windows logging, etc.) aren't all that sophisticated. Due to performance being a main goal, the intrinsics of the whole thing are somewhat complicated (like log message formatters being quite tangled with log sinks), but we did master that (I remember stepping through it in a debugger helping with that) and once understood it wasn't all that hard to write your own message formatters or log sinks.

reliable (don't leak or crash!)

We have used it without finding any such severe issues. There's virtually no dynamic memory allocation in there, so it's hard to even imagine it doing something wrong. Of course, we only ever put it to real-world tests in one product.

cross-platform (at least Windows, MacOSX, Linux/Ubuntu)

When we used it, we used it on Win32, OSX, and several different Linux distributions, Ubuntu among them.

As for multi-threading: We haven't used this, but from what I remember of the lib's architecture it seems you would only need to handle this in log sinks. ICBWT.

share|improve this answer
Thanks, I didn't know this one. It looks like a simplified (and performant) version of boost::log, at least in the original idea. – Klaim Feb 17 '11 at 12:49
@Klaim: I don't think boost had anything to offer when I last looked into C++ logging libraries, so I don't know about boost::log. – sbi Feb 17 '11 at 13:25
@Joe: Do you understand the term "expression templates"?? – sbi Feb 17 '11 at 17:12
I thought I did, but now I have downloaded and started reading the templog source code, and it appears C++ has outwitted me again. – user744 Feb 17 '11 at 17:30
@sbi: Part of my confusion was your statement "passed at once through several layers" - In English at once can mean either immediately or together, which in this case are opposites. I read it as the first, and you (now obviously to me) meant the second. Thanks for taking the time to explain it. – user744 Feb 17 '11 at 17:55

You may wish to consider the logog library, at , which I think may satisfy your requirements. Caveat: I wrote it.

See also other people's answers at .

share|improve this answer
+1: Interesting, I'll take a look. – Klaim Mar 17 '12 at 6:59

You might be interested in Baical tools set:

  • Open source and cross platform (Win, Linux, x86/x64) library for logs, traces & telemetry - P7
  • Incredibly fast (designed for embedded devices) - 3 million of logs per second to network, 5 millions to file on modern CPU. I don't know any other library for logging which provides such speed and so detailed information for every log message.
  • Thread safe
  • Every trace message contains:
    • text message
    • level
    • precise time (100ns)
    • source file, function name & line
    • module ID and module name
    • thread ID and thread name
    • processor core index
  • Server application to receive and view logs & telemetry
  • You may collect, analyze, search, filter logs from multiple sources in real-time
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.