• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Ranjeet Deshmukh
Ranch Hand
Posts: 35
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranjeet Deshmukh
Ranch Hand
Posts: 35
Eclipse IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!