سؤال

I have downloaded Log4Cpp code project and built succesfully on my windows 7 64 bit machine. I have also used properties file in my code in following way -

const char* initFileName = "log4cpp.property";
   log4cpp::PropertyConfigurator::configure(initFileName);

I am using it in a console application so I placed log4cpp.property file in a bin directory where my exe file exist.

But whenever I am trying run 2nd line of code throws exception as given file does not exist. So can some body please help me with directory structure I should follow to use Log4Cpp

Thanks

هل كانت مفيدة؟

المحلول

It can't be in the same directory as the executable file is in, it has to be in the programs current directory, which may or may not be the directory the executable is in.

For example, if you're in the director /home/foo/bar, and run a program in /home/foo/bin/, the current directory is where you are and not where the program is. In the case of this example the /home/foo/bar directory.

You can use e.g. getcwd (_getcwd on Windows) to get the programs current directory.

If your program will always be in the same place, you can use a full path to the property file.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top