java - Write timestamp in logs (every line) and trigger a jar using a batch file -


i have jar file trigger using batch file , want shown on command line window logged along timestamp. need write timestamp in each line written inside logs. this:

tue 06/28/2016,15:42:22.24 -  logssssss tue 06/28/2016,15:42:22.24 -  logssssss tue 06/28/2016,15:42:22.24 -  logssssss ... 

i have following code:

@echo off echo %date%,%time% - %~1 >>output.log call :sub >>output.txt echo %date%,%time% - %~1 >>output.log exit /b  :sub command1 command2 ... commandn 

using able record start , end time of script.

edit 1: want script display execution on screen along writing in file.

edit 2: now, have following code not write logs along execution. please tell me improve.

@echo off setlocal enabledelayedexpansion  set logfile=d:\logs\logfile.out set logg=^> tmp.out^&^& type tmp.out^&^&type tmp.out^>^>%logfile%  if /i "%~1"=="recursive" java test prompt $d,$t$s-$s >> %logg% echo !date!,!time! - %~1 >> %logg% (for /f delims^=^ eol^= %%$ in ('^(for /f delims^^^=^^^ eol^^^= %%# in ^('"%~f0" recursive'^) rem/ %%#^)') echo %%$)  >> %logg% echo !date!,!time! - %~1 prompt exit /b 

the eaiest way use logging framework logback, log4j, etc. you'll need refactor code.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -