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!




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


    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.

  6. Posted August 28, 2018 at 11:18 pm | Permalink

    WhatHappening i am new to this, I stumbled upon this I’ve found It positively helpful and it has aided me out loads. I hope to contribute & assist other users like its helped me. Good job.

  7. Posted June 25, 2019 at 3:29 pm | Permalink

    GCMAvt Really enjoyed this blog.Thanks Again. Cool.

  8. Posted July 11, 2019 at 6:22 pm | Permalink

    An intriguing discussion is worth comment. I do believe
    that you should publish more on this topic, it
    might not be a taboo matter but usually people don’t
    talk about such subjects. To the next! Kind regards!!

2 Trackbacks

  1. By Botox Stars Montreal on October 19, 2019 at 2:05 pm

    Botox Stars Montreal

    Logging file names and line numbers with Boost::Log – Blog

  2. By Independent Escort on November 10, 2019 at 6:27 pm

    Independent Escort

    Logging file names and line numbers with Boost::Log – Blog

Post a Comment

Your email is never shared. Required fields are marked *