kvineeth - 2008-03-14


I have a code which i need to compile on a linux machine.
here is the code
#include    "Category.hh"
#include    "FileAppender.hh"
#include    "BasicLayout.hh"

int main(int argc, char* argv[])
        // 1 instantiate an appender object that
        // will append to a log file
    log4cpp::Appender* app = new

        // 2. Instantiate a layout object
    // Two layouts come already available in log4cpp
    // unless you create your own.
    // BasicLayout includes a time stamp
        log4cpp::Layout* layout =
        new log4cpp::BasicLayout();

    // 3. attach the layout object to the
    // appender object

    // 4. Instantiate the category object
    // you may extract the root category, but it is
    // usually more practical to directly instance
    // a child category
    log4cpp::Category main_cat =

    // 5. Step 1
    // an Appender when added to a category becomes
    // an additional output destination unless
    // Additivity is set to false when it is false,
    // the appender added to the category replaces
    // all previously existing appenders

    // 5. Step 2
        // this appender becomes the only one

    // 6. Set up the priority for the category
        // and is given INFO priority
    // attempts to log DEBUG messages will fail

    // so we log some examples
    main_cat.info("This is some info");
    main_cat.debug("This debug message will
                     fail to write");
    main_cat.alert("All hands abandon ship");

    // you can log by using a log() method with
    // a priority
    main_cat.log(log4cpp::Priority::WARN, "This will
                  be a logged warning");

    // gives you some programmatic control over
    // priority levels
    log4cpp::Priority::PriorityLevel priority;
    bool this_is_critical = true;
        priority = log4cpp::Priority::CRIT;
        priority = log4cpp::Priority::DEBUG;

    // this would not be logged if priority
    // == DEBUG, because the category priority is
    // set to INFO
    main_cat.log(priority,"Importance depends on
    // You may also log by using stream style
    // operations on
    main_cat.critStream() << "This will show up
              << as " << 1 << " critical message"
    << log4cpp::CategoryStream::ENDLINE;
        main_cat.emergStream() << "This will show up as "
        << 1 << " emergency message" <<      

    // Stream operations can be used directly
        // with the main object, but are
        // preceded by the severity level
    main_cat << log4cpp::Priority::ERROR
              << "And this will be an error" 
              << log4cpp::CategoryStream::ENDLINE;

    // This illustrates a small bug in version
    // 2.5 of log4cpp
    main_cat.debug("debug"); // this is correctly
                 // skipped
    main_cat.crit("crit");    // this prints ALERT
                // main_cat : crit   
    main_cat.alert("alert");// this prints PANIC
                // main_cat : alert
    main_cat.emerg("emerg");// this prints UNKOWN
                // main_cat : emerg

    main_cat.debug("Shutting down");// this will
                    // be skipped

    // clean up and flush all appenders
    return 0;

Can anybody suggest me what i need to give as an compilation option to compile it properly.
I tried it from command line this way
@ubuntu:/home/users/vineeth/LOG4C++/log4cpp-1.0/vini$ g++ handle.cpp
handle.cpp: In function âint main(int, char**)â:
/usr/local/include/log4cpp/Category.hh:624: error: âlog4cpp::Category::Category(const log4cpp::Category&)â is private
handle.cpp:20: error: within this context
handle.cpp:51: error: âENDLINEâ is not a member of âlog4cpp::CategoryStreamâ
handle.cpp:52: error: âENDLINEâ is not a member of âlog4cpp::CategoryStreamâ
handle.cpp:55: error: âENDLINEâ is not a member of âlog4cpp::CategoryStreamâ

and it gave me the foll erros