Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Your site is one of the cleanest and BEST forums that I have seen. I have sent quite a few people your way. Keep up the good work!!!"

Geography

Where in the world do Tek-Tips members come from?
mbaranski (Programmer)
2 Mar 01 16:31
I've got a program that does some stuff, and has logging information being printed to one file, other stuff going to cout, and errors going to cerr.  I want to re-direct cerr to a log file, without messing up anything else.  Basically, if there is an option specified in the config file, write cerr to ./error.log, otherwise, write it to /dev/null or whatever.  How do I do this?  Can I just open a fstream object and assing cerr to it?  I'd appreciate an example (simple, of course)

Thanks
Mike B.



Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.

Masi (Programmer)
4 Mar 01 12:22
You could do it at the prompt in this way:
            program_name 2> error.log

Is it enough?
mbaranski (Programmer)
5 Mar 01 14:48
No, that redirects standard out, which I'm using for mysql output.  I'm calling the program like:

./import | mysql -f

Which imports a database by connectiing over a network and pushing the data out to standard out in the mysql file format.  I am printing logging and error messages via cerr, instead of cout, which is currently pointed at the terminial screren, even when piping or re-directing.  I need to open an ostream or something and tell cout to use it to write to a file.

Thanks anyway.



Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close