logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kaspar Fischer <kaspar.fisc...@dreizak.com>
Subject Re: getRootLogger() thread-safe?
Date Mon, 10 Mar 2014 17:32:20 GMT
Hi Thorsten,

Thanks a lot for the quick response! Unfortunately, we use a pre-built
package so I can't patch the code.

However, when I create a static variable

  log4cxx::LoggerPtr log4cxx_root_logger = log4cxx::Logger::getRootLogger();

and use log4cxx_root_logger in my code (instead of
log4cxx::Logger::getRootLogger()), all works fine.

Static local variables are not thread-safe so it looks to me as if you want
to change that - from a user's perspective, it's nice to be able to assume
that getRootLogger() is thread-safe. What do you think?

- Kaspar



On Mon, Mar 10, 2014 at 12:20 AM, Thorsten Schöning
<tschoening@am-soft.de>wrote:

> Guten Tag Kaspar Fischer,
> am Montag, 10. März 2014 um 03:20 schrieben Sie:
>
> > Is getRootLogger() thread safe?
>
> Looks like the same problem as in LOGCXX-394 to me.
>
> https://issues.apache.org/jira/browse/LOGCXX-394
>
> > RepositorySelectorPtr& LogManager::getRepositorySelector() {
> >    //
> >    //     call to initialize APR and trigger "start" of logging clock
> >    //
> >    APRInitializer::initialize();
> >    static spi::RepositorySelectorPtr selector;
> >    return selector;
> > }
>
> > LoggerRepositoryPtr& LogManager::getLoggerRepository()
> > {
> >         if (getRepositorySelector() == 0)
> >         {
> >                 LoggerRepositoryPtr hierarchy(new Hierarchy());
> >                 RepositorySelectorPtr selector(new
> DefaultRepositorySelector(hierarchy));
> >                 getRepositorySelector() = selector;
> >         }
> >
> >         return getRepositorySelector()->getLoggerRepository();
> > }
>
> > LoggerPtr LogManager::getRootLogger()
> > {
> >         // Delegate the actual manufacturing of the logger to the logger
> repository.
> >         return getLoggerRepository()->getRootLogger();
> > }
>
> Could try to just remove the "static" in the following line?
>
> >    static spi::RepositorySelectorPtr selector;
>
> If that works, we'll consider just removing that on trunk as well,
> like with LOG4CXX-394.
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail:Thorsten.Schoening@AM-SoFT.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon...........05151-  9468- 55
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>

Mime
View raw message