Forums Register Login

Logging output of a batch file to log file in Java.

+Pie Number of slices to send: Send
Hi All,

I'm using batch file in java to accomplish certain task. Currently I'm getting output of this batch file inside Eclipse console. I want to create a log file under the same project and overwrite these logs each time.

Please find my code below:

1
+Pie Number of slices to send: Send
Instead of using System.out.print(...), which prints to the console, you can open a file and write to the file (using for example a FileOutputStream).

Can you explain in more detail what you want to know?

Oracle has a good set of tutorials about I/O, where you can learn how to write data to a file.

Even better would be to use a logging framework such as Logback or Log4J for logging.
1
+Pie Number of slices to send: Send
 

Jesper de Jong wrote:Instead of using System.out.print(...), which prints to the console, you can open a file and write to the file (using for example a FileOutputStream).

Can you explain in more detail what you want to know?

Oracle has a good set of tutorials about I/O, where you can learn how to write data to a file.

Even better would be to use a logging framework such as Logback or Log4J for logging.




Hi Jesper de Jong,

Thanks for the quick help.. it worked fine with FileOutputStream.


He's my best friend. Not yours. Mine. You can have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2331 times.
Similar Threads
Should the streams in process be closed inspite of calling destroy
how to retieve the keys and values from a propertyfile in an order
Wrapper application cannot execute scripts properly
Runtime.exec() file problem
Runtime exec on different windows platforms
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:05:12.