I would like to know how i can replace an outputline with a write to a log file? Ive tried searching but no luck.

Recommended Answers

All 2 Replies

I would like to know how i can replace an outputline with a write to a log file? Ive tried searching but no luck.

I consider that bad joke since simple google search with "java message logging" brings millions of results where each of them mention either log4j or slf4j. Each of provided links goes directly to user manual.

Do you mean redirect System.out.print... to a file?
If so:

PrintStream printStream = new PrintStream(new FileOutputStream(fileName, true, true); // true for append and autoflush)
System.setOut(printStream);
System.setErr(printStream);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.