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

19 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.

  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!!

  9. Posted November 30, 2019 at 1:39 pm | Permalink

    Hi there, You’ve done a great job. I’ll definitely digg it and personally suggest to my friends.
    I’m confident they’ll be benefited from this website.

  10. Posted December 21, 2019 at 2:58 am | Permalink

    What’s up, after reading this awesome piece of writing i am too happy to share my know-how
    here with colleagues.

  11. Posted January 7, 2020 at 10:46 pm | Permalink

    I feel this is among the most vital information for me.
    And i’m happy studying your article. But want to observation on some general issues, The site style is great, the articles is in reality excellent :
    D. Excellent process, cheers

  12. Posted March 2, 2020 at 1:52 am | Permalink

    sehabis mmembaca blog ini saya bisa mendeskripsikan bahwa penulisan yang di jelaskan bermanfaat.

  13. Posted March 2, 2020 at 8:53 pm | Permalink

    menurut saya blog yang anda tulis ini menjadi inspirasi banyak orang.
    Thank you gan.

  14. Posted March 5, 2020 at 10:56 am | Permalink

    Wah,blognya bagjs nih gan bisa buat referensi kita kalo lagi bikin artikel

  15. Posted March 7, 2020 at 12:54 pm | Permalink

    Penulisan artikel ini jelas memberikan informasi yang bermanfaat gan. Terutama
    membuat saya menjadi termotivasi untuk mencari info seperti itu.

  16. Posted March 13, 2020 at 11:17 am | Permalink

    Ini dia, informasi yang akurat, menarik, dan lengkap. Makaih ya gan saya akan mempelajari lebih dalam
    lagi dari info tersebut.

  17. Posted March 20, 2020 at 8:27 pm | Permalink

    Tulisan artikelnya bagus gan, sangat bermanfaat sekali. Salam kenal
    ya semoga saya bisa melakukan apaa yang sudah di tuliskan.

  18. Posted March 21, 2020 at 12:41 pm | Permalink

    Betul banget. Artikelnya sangat bermanfaat min. Tambah info-info menarik
    lainnya ya min.

  19. Posted March 25, 2020 at 3:55 pm | Permalink

    dari banyaknya sumber informasi, sepertinya blog agan adalah yang
    paling tepat. Karena disini saya bisa mendapatkan pelajaran yyang sangat berarti.

16 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

  3. By $1 Slot on November 14, 2019 at 12:45 am

    $1 Slot

    blog topic

  4. By Improvement Offered on November 20, 2019 at 5:07 pm

    Improvement Offered

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

  5. By Hotel Escort on November 24, 2019 at 9:43 pm

    Hotel Escort

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

  6. By jasa backlink murah on January 9, 2020 at 3:06 am

    jasa backlink murah

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

  7. By Nearby Paint on January 9, 2020 at 3:07 pm

    Nearby Paint

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

  8. By coba ini on January 12, 2020 at 9:31 am

    coba ini

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

  9. By Bazbrothersproduction.com on January 13, 2020 at 10:19 am

    Bazbrothersproduction.com

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

  10. By klik saja artikel yang akan datang on January 14, 2020 at 5:21 am

    klik saja artikel yang akan datang

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

  11. By judi dadu uang asli on January 17, 2020 at 10:01 pm

    judi dadu uang asli

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

  12. By karpet tile on January 18, 2020 at 2:58 am

    karpet tile

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

  13. By slot online uang asli on January 25, 2020 at 5:58 pm

    slot online uang asli

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

  14. By 릴게임사이트 on January 29, 2020 at 12:01 pm

    릴게임사이트

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

  15. By Chris Quintela on February 23, 2020 at 12:10 am

    Chris Quintela

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

  16. By Chris Quintela and Lucid Leverage on March 24, 2020 at 8:52 pm

    Chris Quintela and Lucid Leverage

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

Post a Comment

Your email is never shared. Required fields are marked *

*
*