Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9203605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:30:35+00:00 2026-06-17T23:30:35+00:00

Is it possible to programmatically configure log4cpp? I want to configure it as it

  • 0

Is it possible to programmatically configure log4cpp?

I want to configure it as it would be configured by supplying the following config file.

appender root basic console
priority root DEBUG
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:30:36+00:00Added an answer on June 17, 2026 at 11:30 pm

    Do you mean log4cpp from http://sourceforge.net/projects/log4cpp/ ?

    The short answer is yes.

    Here are some sample codes, and you can figure out more details based on its doc:

    My codes are used to configure file-based log4cpp instance at run-time.

    “priority” is ‘DEBUG’, …
    “name” here is ‘root’
    “layout” could be “%d{%Y-%m-%d %H:%M:%S}%c %x: %m%n”

    // Create RollingFileAppender
    log4cpp::Appender *rfileAppender = new log4cpp::RollingFileAppender(std::string(name),
            std::string(fileName),
            maxFileSize,
            maxBackupIndex,
            append,
            mode);
    
    if (rfileAppender != NULL)
    {
        // Create PatternLayout
        log4cpp::Layout *layout = new log4cpp::PatternLayout();
    
        if (layout != NULL)
        {
            try
            {
                // Set up Pattern
                ((log4cpp::PatternLayout *)layout)->setConversionPattern(std::string(layoutPattern));
    
                // Bind Layout to RollingFileAppender
                rfileAppender->setLayout(layout);
    
                category.setAdditivity(additivity);
    
                try
                {
                    category.setPriority(log4cpp::Priority::getPriorityValue(std::string(priority)));
                }
                catch(std::invalid_argument &ia)
                {
                    std::cerr << "Invalid Priority: "  << priority << std::endl;
                    category.setPriority(log4cpp::Priority::INFO);
                }
    
                // Bind RollingFileAppender to Category
                category.addAppender(rfileAppender);
    
                return 0;
            }
            catch(log4cpp::ConfigureFailure &cf)
            {
                std::cerr << cf.what() << std::endl;
                return 1;
            }
        }
        else
        {
            std::cerr << "Cannot initialize PatternLayout" << std::endl;
            return 1;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Programmatically get own phone number in iPhone OS I want to get
Is it possible to programmatically call another .apk file from my current Application in
Is it possible to programmatically, or otherwise, increase the width of the Windows console
Is it possible to programmatically break into debugger from GCC? For example I want
Is it possible to programmatically resolve a URL to a file using ASP.NET and
Possible Duplicate: Programmatically delete my own app Currently I am working on a iphone
Is it possible to programmatically enable Desktop Sync for a folder via the Box.com
Is it possible to programmatically alter a ARMv7-compiled binary to replace all the new
Is it possible to programmatically create a DBLink in SQL server 2005 in C#?
Is it possible to programmatically zip/unzip files in vb.net? Meaning, not that it will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.