logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Picaso <pic...@roltaus.com>
Subject runtime error (Unable to open log file) while configuring FileApp ender
Date Tue, 29 Jun 2004 23:54:07 GMT
Hi, 
I have compiled log4cxx-0.9.7 in VC++ 6.0 (win 2000 server). I could compile

the libraries / dll's. Now to get started, I am trying to configure the 
logger using configuration file. The contents are as follows: 

log4j.rootLogger=debug, stdout, R 
log4j.appender.stdout=org.apache.log4j.ConsoleAppender 
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n 
log4j.appender.R=org.apache.log4j.FileAppender 
log4j.appender.R.File="commonexit.log" 
log4j.appender.R.layout=org.apache.log4j.PatternLayout 
log4j.debug=true 

My c++ code written in trival.cpp is as follows: 

#include <stdlib.h> 
#include <log4cxx/logger.h> 
#include <log4cxx/basicconfigurator.h> 
#include <log4cxx/propertyconfigurator.h> 
#include <log4cxx/helpers/exception.h> 
#include <log4cxx/ndc.h> 

using namespace log4cxx; 
using namespace log4cxx::helpers; 

int main() 
{ 
    int result = EXIT_SUCCESS; 
    try 
    { 
        LoggerPtr logger = Logger::getLogger(_T("trivial")); 
        USES_CONVERSION; 
        String propertyFileName = A2W("C:\\CommonExit.cfg"); 
        PropertyConfigurator::configure(propertyFileName); 
        logger->info(_T("APPS INITIALIZED")); 
    } 
    catch(Exception&) 
    { 
        result = EXIT_FAILURE; 
    } 
    return result; 
} 

/////////////////// 

I compile the exe using with follwing project settings: 
C/C++ settings: 
preprocessor definitions: WIN32,_DEBUG,_CONSOLE,_MBCS,UNICODE 

Link settings: 
Object/Library modules: log4cxx.lib 

Now when i run the exe i get the following output on my screen: 

Parsing for [root] with value=[debug, stdout, R]. 
Level token is [debug]. 
OptionConverter::toLevel: no class name specified, level=[debug] 
Category root set to DEBUG 
Parsing appender named "stdout". 
Parsing layout options for "stdout". 
Setting option name=[ConversionPattern], value=[%5p [%t] (%F:%L) - %m%n] 
End of parsing for "stdout". 
Parsed "stdout" options. 
Parsing appender named "R". 
Parsing layout options for "R". 
End of parsing for "R". 
Setting option name=[File], value=["C:\Program Files\CA\eTrust 
Admin\Logs\common 
exit.log"] 
FileAppender::activateOptions called : "commonexit.log", 1 

Unable to open file: "commonexit.log" 

Parsed "R" options. 
Finished configuring. 
 INFO [2208] (:-1) - APPS INITIALIZED FROM EXE 
///////////////////// 

Ulitimately, my logfile is not created and I am not able to figure out the 
reason why it's not able to open a file. I even tried to create the file and

then run the application, but still get the same error. When i debugged, i 
found out that it fails in the following function: 
/////////       
ofs.open(T2A(fileName.c_str()), (append ? std::ios::app : 
                std::ios::trunc)|std::ios::out); 

        if(!ofs.is_open()) 
        { 
                throw RuntimeException();  //goes here all the times 
        } 

////////// 

I will really appreciate if somebody can help me out with the above problem.

Best Wishes, 
Picaso 

Mime
View raw message