Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Need URGENT help on Log4cpp....

807578Mar 20 2006 — edited May 18 2006
Hi all,

I have written a C++ program which uses Log4cpp. Here I have written the following statement to use property file-
log4cpp::PropertyConfigurator::configure ("/home/tests/log/testlog.properties");

-as the first statement of the program(within main). But the program did not run. I am getting the following error when I am trying to run -

Abort process (core dumped)

Also I do not know exactly how to write properties file. I have taken this prop file content from Net.
For your convenience I am writing the prop file & main file contents.

Prop File :
-----------
# a simple test config

log4j.rootCategory=DEBUG, rootAppender
log4j.category.sub1=A1
log4j.category.sub2=INFO
log4j.category.sub1.sub2=ERROR, A2

log4j.appender.rootAppender=org.apache.log4j.ConsoleAppender
log4j.appender.rootAppender.layout=org.apache.log4j.BasicLayout

log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.fileName=A1.log
log4j.appender.A1.layout=org.apache.log4j.BasicLayout

log4j.appender.A2=org.apache.log4j.ConsoleAppender
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.pattern=The message %m at time %d%n


Main File:
----------

#include "log4cpp/Category.hh"
#include "log4cpp/FileAppender.hh"
#include "log4cpp/BasicLayout.hh"
#include "log4cpp/PropertyConfigurator.hh"

int main(int argc, char* argv[])
{
log4cpp::PropertyConfigurator::configure ("/home/tests/log/testlog.properties");
log4cpp::Appender* app = new
log4cpp::FileAppender("FileAppender","/home/tests/testlog4cpp.log");
log4cpp::Layout* layout =
new log4cpp::BasicLayout();
app->setLayout(layout);
log4cpp::Category& main_cat =
log4cpp::Category::getInstance("main_cat");
main_cat.setAdditivity(false);
main_cat.setAppender(app);
main_cat.setPriority(log4cpp::Priority::INFO);

main_cat.info("This is some info");
main_cat.debug("This debug message will fail to write");
main_cat.alert("All hands abandon ship");
main_cat.log(log4cpp::Priority::WARN, "This will be a logged warning");
log4cpp::Category::shutdown();
return 0;
}

....Please help me because it is very very very urgent.

With Regards,
Palak
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 15 2006
Added on Mar 20 2006
3 comments
555 views