You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Fa...@nucorsteel.com on 2004/07/21 17:01:18 UTC

Re: A Newbie Question About Examples [Resolved]





I found my answer, sorry for not doing my homework. In case anyone stumbles
across this thread, the answer is here:

http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx-user@logging.apache.org&msgNo=111

Alex



                                                                           
             FabijanicA@nucors                                             
             teel.com                                                      
                                                                        To 
             07/21/2004 10:42          log4cxx-user@logging.apache.org     
             AM                                                         cc 
                                                                           
                                                                   Subject 
             Please respond to         A Newbie Question About Examples    
              "Log4CXX User"                                               
             <log4cxx-user@log                                             
             ging.apache.org>                                              
                                                                           
                                                                           
                                                                           








 I am not able to run the examples from the introduction document (VC++
6.0). Simple copy/paste of the code dies with console error message "You
have tried to set a null level to root.".

I was able to get the app to complete (quick & dirty and the above
mentioned error still prints out) by adding constructor to bar as follows
(code somewhat condensed for brevity) :

Bar::Bar() {
    TTCCLayout* layout = new TTCCLayout;
    ConsoleAppender* console = new ConsoleAppender(layout);
    this->logger->addAppender(console);
}

and then modify main as follows:

LoggerPtr rootLogger = Logger::getRootLogger();

int main(int argc, char **argv) {
        rootLogger->setLevel(Level::DEBUG);
        LoggerPtr logger = Logger::getLogger(_T("MyApp"));
        int result = EXIT_SUCCESS;
        try    {
                BasicConfigurator::configure();
                logger->info(_T("Entering application."));
                Bar bar;
                bar.doIt();
                logger->info(_T("Exiting application."));
        }
        catch(Exception&)        {
                result = EXIT_FAILURE;
        }
        return result;
}

Any help appreciated.

+++
Aleksandar Fabijanic
Level 2 Automation Engineer
Nucor Steel Berkeley - Beam Mill
Phone: 843.336.6678
Fax:      843.336.6072
---