Easy error logging

How to use OUTPUT redirecting to create logs


command can equal anything like adb devices or echo process finished. It really doesn't mater be creative.

command > Logfile.txt

This creates a new file each time it's run

command >> Logfile.txt

This appends to the Logfile.txt each time it's run.


Errors still go to the screen. Some commands send info to the Error output, so that goes to the screen as well.

To capture that in a file, add 2>&1 to the line like so:

command > Logfile.txt 2>&1

You can use this to stop a output completely

command > nul

typescript
@title Error logging with redirects @echo off :: set is used to make the letter L = logfile.txt and can be called with %L% set L=logfile.txt :: call the LOG section of the script. call :LOG :LOG echo Logged time = %time% %date% > %L% 2>&1 adb.exe devices >> %L% 2>&1 >> %L% 2>&1 echo App Install = Pass echo App Install = Pass >> %L% 2>&1 echo App Install = Pass >> %L% 2>&1 echo App Install = Pass >> %L% 2>&1 echo App Install = Pass >> %L% 2>&1 echo App Install = Pass >> %L% 2>&1 pause exit