> 2010/8/20 Olivier Tournaire <
olitour@gmail.com>
>>
>> OK. However, I do not understand why this formatter (and only this one)
>> goes out of scope. How can I move it to a global scope to avoid the current
>> behavior (std::nothrow works likes a charm)?
>
> The macro BOOST_LOG_SCOPED_THREAD_ATTR registers an attribute at the current
> scope, and unregisters it when the current scope exits. In your code, this
> line is used in your class constructor:
>
> BOOST_LOG_SCOPED_THREAD_ATTR("Uptime", attrs::timer);
>
> This attribute will work for every BOOST_LOG() or BOOST_LOG_SEV() issued in
> the scope where this attribute was registered. In your case, you are doing a
> log message from the a_test_method_to_see_if_the_logger_is_still_working()
> function. When this function is executed, the attribute is no longer in
> scope (as the constructor is already run, hence attribute is no longer in
> scope) and when the formatting step is done at this time, the attribute does
> not exist and that is why the exception is thrown.
> To make this attribute work everywhere you should put the line above that
> registers the attribute in your main() function before any logging is done.