Extracting messages from Ofconsole in DCMtk - DICOM

This is a discussion on Extracting messages from Ofconsole in DCMtk - DICOM ; can somebody tell how to extract the messages from ofConsole. I want to write them to a log file.(eg.c:\\dicomlog).I want to write the output from cout and cerr statements i tried to use OFConsole::setCout() and OFConsole::setCerr() statements in a function ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Extracting messages from Ofconsole in DCMtk

  1. Extracting messages from Ofconsole in DCMtk

    can somebody tell how to extract the messages from ofConsole. I want
    to write them to a log file.(eg.c:\\dicomlog).I want to write the
    output from cout and cerr statements



    i tried to use OFConsole::setCout() and OFConsole::setCerr()
    statements in a function called writelog().

    static void WriteLog()
    {
    //ofstream argv[10];
    //int argc = 0;
    ofstream out("c:\\test.log", ios:ut | ios::binary);
    if(!out) {
    cout << "Cannot open output file.\n";
    return ;
    }

    static ostream *log_stream =&CERR;
    log_stream = &out;

    ofConsole.join();
    ofConsole.setCerr(&out);
    ofConsole.setCout(&out);

    }


    but this seems to be of no use if i use this function in DCMTK..some
    it does write the address of the variable but it does not write down
    the log....can somebody help me out on this...Thanking you

  2. Re: Extracting messages from Ofconsole in DCMtk

    On Mar 6, 2:24 pm, sriram bala wrote:
    > can somebody tell how to extract the messages from ofConsole. I want
    > to write them to a log file.(eg.c:\\dicomlog).I want to write the
    > output from cout and cerr statements
    >
    > i tried to use OFConsole::setCout() and OFConsole::setCerr()
    > statements in a function called writelog().
    >
    > static void WriteLog()
    > {
    > //ofstream argv[10];
    > //int argc = 0;
    > ofstream out("c:\\test.log", ios:ut | ios::binary);
    > if(!out) {
    > cout << "Cannot open output file.\n";
    > return ;
    > }
    >
    > static ostream *log_stream =&CERR;
    > log_stream = &out;
    >
    > ofConsole.join();
    > ofConsole.setCerr(&out);
    > ofConsole.setCout(&out);
    >
    > }
    >
    > but this seems to be of no use if i use this function in DCMTK..some
    > it does write the address of the variable but it does not write down
    > the log....can somebody help me out on this...Thanking you


    Hey Guys,
    I used freopen() API call which redirect logs from the storescp which
    work fine...

+ Reply to Thread