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 7767567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:42:36+00:00 2026-06-01T15:42:36+00:00

I have a logging functionality and in this I have got log files. Now

  • 0

I have a logging functionality and in this I have got log files. Now every time I run the program I want that previously written file should not get deleted and should be appended with the current data (what ever is there in the log file)

Just to make it clear for example: I have a log file logging_20120409.log which keeps the timestamp on a daily basis. Suppose I run my project it writes to it the current timestamp. Now if I rerun it the previous timestamp gets replaced with it. I do not want this functionality. I want the previous time stamp along with the current time stamp.

Please help

  • 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-01T15:42:37+00:00Added an answer on June 1, 2026 at 3:42 pm

    You want to open the file in “append” mode, so it doesn’t delete the previous contents of the file. You do that by specifying ios_base::app when you open the file:

    std::ofstream log("logfile.txt", std::ios_base::app | std::ios_base::out);
    

    For example, each time you run this, it will add one more line to the file:

    #include <ios>
    #include <fstream>
    
    int main(){
        std::ofstream log("logfile.txt", std::ios_base::app | std::ios_base::out);
    
        log << "line\n";
        return 0;
    }
    

    So, the first time you run it, you get

    line
    

    The second time:

    line
    line
    

    and so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a diagnostic log that is produced by several tasks managing
On my Asp.Net MVC 3 site I have an error logging functionality that sends
Does NLog have any sort of functionality to consolidate repetitive log messages when logging
I have seen jquery-ui-1.8.11.js verify console.log functionality by doing if (this.debug) console.log() I have
I have a logging class that stores entries in a datatable dt. I then
I have a little logging app (written in wxPython) that receives data from a
I have a commons-logging configuration question. I want it to use SimpleLog (instead of
Currently I have a static class that I use as my logging module. I’ve
I have this code for logging into Google using Simple DOM Parser with curl.
I have a task to add logging functionality to the existing workflow based solution.

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.