Logging file names and line numbers with Boost::Log

I recently started using Boost::Log, and in general, I like it.  One glaring deficiency, though, is that it doesn’t log file names and line numbers.  This is really irritating, especially since it’s such basic functionality, and it’s the one thing all logging frameworks do.  I wrote a bit of C++ that adds this by adding the file name and line number as custom attributes to the log record.  I’ve attached a sample that shows how to use it.

Happy logging!

log.h

log.cc

5 Comments

  1. Posted October 30, 2013 at 1:29 am | Permalink

    Hello,

    I’m also starting with Boost, struggling with it indeed :) and I would need to log file names and lines, so your blog post was providential for me. Thank you for that.

    However I’m having some issues that I don’t understand and I’m not sure if you could help me, because sometimes one needs the help of others to find the evident errors or mistakes that cannot find by himself. The problem I have is that when I add the streams to my backend, some syntax errors appear. They says that an invalid syntax is used but I’m quite sure it is not the point. The code of the program is in Paste bin, in this link http://pastebin.com/LKT2HW8g
    and the error appears in the 107 line of code, just in add_stream.

    I’m still looking for a solution and I understand that you could be too busy to help me on this, but if you had some similar problem to this one and could help me, it woulg be great. Thank you anyway!

  2. Posted January 29, 2017 at 6:49 pm | Permalink

    It’s awesome in favor of me to have a website, which is
    useful designed for my experience. thanks admin

  3. Posted January 29, 2017 at 7:30 pm | Permalink

    Good way of telling, and nice piece of writing to get data
    concerning my presentation subject matter, which
    i am going to present in school.

  4. Posted May 18, 2017 at 6:42 am | Permalink

    Hello, this weekend is nice designed for me, since this moment i am reading
    this wonderful educational article here at my house.

  5. Posted May 18, 2017 at 7:11 am | Permalink

    Excellent, what a web site it is! This webpage gives helpful
    data to us, keep it up.

Post a Comment

Your email is never shared. Required fields are marked *

*
*