How To Output a Message to Both a File and Console
Posted on 2008-06-09
In a DOS\Console batch file I need to output all information (standard output and error output) to both the screen AND a log type file. Ideally I Do NOT want to use two lines every time I need to output a message (one to screen and one to file - yuk). Here is an example output line:
echo %time% - Transferring %FILE_TYPE%
I know I can append this to a file using:
echo %time% - Transferring %FILE_TYPE% >> %MYFILE%
echo %time% - Transferring %FILE_TYPE% >> %MYFILE% 2>&1
My problem is if the above is used I do not get any screen output. I feel I am close.
What can you suggestion?
When I do this I cannot