title: what's best way to use boost::log for multi-threading apps with extra 'channel' and 'id' attribute
body: <p>I want to do logging in a multithreaded app to both console and file, the logging line should be like:  </p>
  
  <blockquote>
    <p>2011-07-18 14:48:51.849 100 CORE W : message</p>
  </blockquote>
  
  <ol>
  <li>100 is unique id</li>
  <li>'CORE' is a channel, I can have more channels, e.g. DATA, NETWORK.</li>
  <li>'W' means warning</li>
  </ol>
  
  <p>Currently I tried, roughly:</p>
  
  <pre><code>boost::log::sources::severity_logger&lt; Severity &gt; sevlogger;
  
  enum Channel{Core, ...};
  attrChannel.reset(new boost::log::attributes::mutable_constant&lt; Channel &gt;(Core));
  boost::log::core::get()-&gt;add_global_attribute( "Channel", *attrChannel);
  ...
  //similar to id
  ...
  //file sink:
  typedef boost::log::sinks::synchronous_sink&lt; boost::log::sinks::text_file_backend &gt; FileSinkType;
  fileSink.reset( new FileSinkType( boost::log::keywords::file_name = fileName ));
  fileSink-&gt;locked_backend()-&gt;set_formatter( format );
  boost::log::core::get()-&gt;add_sink( fileSink );
  ...
  //similar thing for console sink
  ...
  
  //LOG Macro
  #define LOG( ch, message )\
      {\
         if( ::Logging::initialized )\
          {\
              boost::mutex::scoped_lock _(::Logging::loggerMutex);\
              unsigned int logID = ::Logging::IncrementLogID();\
              ::Logging::attrChannel-&gt;set(::Logging::ch);\
              ::Logging::attrLogID-&gt;set( logID );\
              BOOST_LOG_STREAM_WITH_PARAMS((::Logging::sevlogger),\
              (::boost::log::keywords::severity = ::Logging::sev )) &lt;&lt; message;\
                  tls-&gt;logID = logID;\
                  tls-&gt;channel = ::Logging::ch;\
              }\
          }
  </code></pre>
  
  <p>It seems 'locking the mutex' is a <strong><em>bottleneck</em></strong> since I have many threads logging at the same time, but I need lock to have unique 'log id', kinda dilemma here, who can help?</p>