Boost logo

Boost Users :

Subject: [Boost-users] [Log] Some questions on severity_logger usage
From: Olivier Tournaire (olitour_at_[hidden])
Date: 2010-08-17 02:53:02


Hi all,

I am trying to use Boost.Log for my application. The log code is in shared
library (a plugin). Here is how I set up my .so logging, according to the
documentation:

// ville_numerique_logging.hpp

#include <boost/log/common.hpp>

#include <boost/log/core.hpp>

#include <boost/log/trivial.hpp>

#include <boost/log/filters.hpp>

#include <boost/log/formatters.hpp>

#include <boost/log/utility/init/to_file.hpp>

 enum severity_level

{

    normal,

    notification,

    warning,

    error,

    critical

};

 BOOST_LOG_DECLARE_GLOBAL_LOGGER_INIT(my_logger,
boost::log::sources::severity_logger< >)

{

    boost::log::init_log_to_file

    (

        boost::log::keywords::file_name = "/home/olivier/ville_numerique.log",

        boost::log::formatters::attr< unsigned int >("LineID"),

        boost::log::keywords::format = "[%TimeStamp%]: %_%"
     // log record format

    );

 // boost::log::core::get()->set_filter

// (

// boost::log::filters::attr<
boost::log::trivial::severity_level >("Severity") >=
boost::log::trivial::info

// );

     return boost::log::sources::severity_logger< >();

}

In some of my method, I then try lo log:

      src::severity_logger< >& lg = my_logger::get();

    BOOST_LOG_SEV(lg, normal) << "A regular message";

    BOOST_LOG_SEV(lg, warning) << "Something bad is going on but I can
handle it";

    BOOST_LOG_SEV(lg, critical) << "Everything crumbles, shoot me now!";

But, nothing happens. The file is not created.

If I uncomment the set_filter lines, it throws an exception: "Requested
attribute value not found"

Could you please help? I am fighting with this for a too long time now.

Regards,

Olivier

-----------------------------------------------------
Olivier Tournaire
MATIS - Institut Géographique National
73, Ave de Paris
94165 St Mandé cedex, France

tel: (+33) 1 43 98 84 29
fax: (+33) 1 43 98 85 81



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net