title: Boost.log synchronization problem
body: <p>I trying to use Boost.log library from Andrey Semashev</p>
  
  <p>I have some problem with multithreaded-logging with settings file.</p>
  
  <p>Code of main program:</p>
  
  <pre><code>namespace logging = boost::log;
  namespace attrs = boost::log::attributes;
  namespace src = boost::log::sources;
  using boost::shared_ptr;
  
  // Here we define our application severity levels.
  enum severity_level
  {
      normal,
      notification,
      warning,
      error,
      critical
  };
  
  BOOST_LOG_DECLARE_GLOBAL_LOGGER(test_lg, src::severity_logger_mt&lt;&gt;)
  
  void try_logging( std::string c )
  {
      BOOST_LOG_SCOPED_THREAD_TAG("Tag", std::string, c.c_str());
  
      src::severity_logger_mt&lt;&gt;&amp; lg = get_test_lg();
      BOOST_LOG_SEV(lg, normal) &lt;&lt; "This is a normal severity record";
      BOOST_LOG_SEV(lg, notification) &lt;&lt; "This is a notification severity record";
      BOOST_LOG_SEV(lg, warning) &lt;&lt; "This is a warning severity record";
      BOOST_LOG_SEV(lg, error) &lt;&lt; "This is a error severity record";
      BOOST_LOG_SEV(lg, critical) &lt;&lt; "This is a critical severity record";
  }
  
  int main(int argc, char* argv[])
  {
      try
      {
          // Open the file
          std::ifstream settings("settings.txt");
          if (!settings.is_open())
          {
              std::cout &lt;&lt; "Could not open settings.txt file" &lt;&lt; std::endl;
              return 1;
          }
  
          // Read the settings and initialize logging library
          logging::init_from_stream(settings);
  
          shared_ptr&lt; logging::attribute &gt; attr(new attrs::local_clock);
          logging::core::get()-&gt;add_global_attribute("TimeStamp", attr);
  
          boost::thread_group g;
          for (char i = 'a'; i &lt; 'z'; i++)
              g.create_thread(boost::bind(&amp;try_logging, std::string("aaa") + i));
  
          g.join_all();
          system("PAUSE");
          return 0;
      }
      catch (std::exception&amp; e)
      {
          std::cout &lt;&lt; "FAILURE: " &lt;&lt; e.what() &lt;&lt; std::endl;
          return 1;
      }
  }
  </code></pre>
  
  <p>Settings file:</p>
  
  <pre><code>[Core]
  
  Filter="%Severity% &gt;= 2"
  
  [Sink:2]
  
  Destination=TextFile
  FileName=test.log
  AutoFlush=true
  Format="[%TimeStamp%] %Tag% %_%"
  Asynchronous=1
  Filter="%Tag% = aaab"
  
  [Sink:3]
  Filter="%Tag% = aaaa"
  Asynchronous=1
  Destination=TextFile
  FileName=test.log
  AutoFlush=true
  Format="%Tag% %_%"
  </code></pre>
  
  <p>As you see, i setup filtering: i want to output just messages from aaab, aaaa threads.</p>
  
  <p>But result file is very bad:</p>
  
  <pre><code>[2011-Jul-18 11:32:58.078192] aaab This aaaa This is a error severity [2011-Juaaaa This is a critical severity record
  r severity record
  [2011-Jul-18 11:32:58.437581] aaab This is a critical severity record
  </code></pre>
  
  <p>One message override other! As I understood - there's no synchronyzing between multiple threads. </p>
  
  <p>If i remove filtering - result is all rigth.</p>
  
  <p>How i can fix it? If it's possible - with config file, not code. </p>
  
  <p>Thank you.</p>