Hi,

Just a wild guess:

Since the difference between your test program and the Boost example is that you are doing all the preparations in the constructor, whilst Boost example has everything in the main() scope. My guess is something goes out of scope at the end of the constructor, and some attribute is unregistered and thus generates "missing attribute" exception.

Regards,
Oskar


2010/8/19 Olivier Tournaire <olitour@gmail.com>
Hi all,

Sorry to insist, but can someone help on boost::logging? Is there a dedicated mailing list?

Regards,

Olivier

2010/8/17 Olivier Tournaire <olitour@gmail.com>
Hi all,

i am currently trying to use Boost.Log in my application. After fighting the two last days, I still do not understand how to correctly use the lib. I would like the result to be the same as the one provided by the example advanced_use.cpp. So, I wrote a simple class to make some tests.
As I want to use the logging library in a shared library (an application plugin), I made a simple test: compile the class which uses Log in a shared library and link an executable against this library. I also have created an executable which directly compiles the class (so does not link against the shared library). Basically, I have a test_boost_log class. The constructor is a copy/paste of the code from the example advanced_use.cpp:

[snip]

test_boost_log::test_boost_log()
{
    [...]
}

I have added another method to test the logger state:


void test_boost_log::a_test_method_to_see_if_the_logger_is_still_working()
{
    src::severity_logger< severity_level > slg;
    BOOST_LOG_SEV(slg, error) << "An error severity message, will pass to the output";
}
My main:

#include "test_boost_log.hpp"

int main(int argc, char** argv)
{
    test_boost_log tbl;
    tbl.a_test_method_to_see_if_the_logger_is_still_working();
    return 0;
}
Here is the output of the program:

Hello, World!
1 [17.08.2010 21:22:43.083302] [] [00:00:00.000076] [test_boost_log::test_boost_log()] Some log line with a counter
2 [17.08.2010 21:22:43.083445] [] [00:00:00.000217] [test_boost_log::test_boost_log()] Another log line with the counter
3 [17.08.2010 21:22:43.083484] [] [00:00:00.000256] [Tagged line] [Tagging scope<-test_boost_log::test_boost_log()] Some tagged log line
4 [17.08.2010 21:22:43.083517] [] [00:00:00.000289] [Tagged line] [Tagging scope<-test_boost_log::test_boost_log()] Another tagged log line
5 [17.08.2010 21:22:43.083556] [] [00:00:00.000328] [test_boost_log::test_boost_log()] Now the tag is removed
6 [17.08.2010 21:22:43.083598] [error] [00:00:00.000370] [test_boost_log::test_boost_log()] An error severity message, will pass to the output
7 [17.08.2010 21:22:43.083633] [normal] [00:00:00.000405] [IMPORTANT MESSAGES] [test_boost_log::test_boost_log()] Some really urgent line
9 [17.08.2010 21:22:43.083673] [] [00:00:00.000444] [int foo(boost::log_mt_posix::sources::logger&)<-test_boost_log::test_boost_log()] foo is being called
8 [17.08.2010 21:22:43.083668] [] [00:00:00.000440] [test_boost_log::test_boost_log()] The result of foo is 10
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::log_mt_posix::missing_value> >'
  what():  Requested attribute value not found

So, the logger throws, sample.log is created, but empty. The library and the executable are compiled with 
-DBOOST_LOG_USE_CHAR
and
-DBOOST_LOG_DYN_LINK

If someone could help...

Best regards,

Olivier

PS: boost_1.42, log_1.0 (from sourceforge), g++4.3.4, 64bits ubuntu


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users