Reputation: 170
I have the following example code :
import java.util.logging.Logger;
public class LoggingExample {
private static final Logger LOGGER = Logger.getLogger(
Thread.currentThread().getStackTrace()[0].getClassName() );
public static void main(String[] args) {
LOGGER.setLevel(Level.ALL);
LOGGER.info("Logging an INFO-level message");
LOGGER.fine("Logging an INFO-level message2");
}
}
With the output to console of:
05/06/2014 12:07:09 ztesting.Loger.LoggingExample main
INFO: Logging an INFO-level message
And I have several question:
P.S. I m using netbeans 6.9
ALSO tried using the following links and it got me no where
Is there any way to remove the information line from java.util.logging.Logger output?
How do I get java logging output to appear on a single line?
Thanks for any help ..
Upvotes: 0
Views: 796
Reputation: 6173
Most of your questions are answered in different tutorials available for java.util.logging
. One example here
You should also read the javadoc.
"Can I not display the first line "05/06/2014 12:07:09 ztesting.Loger.LoggingExample main"
Yes, using Formatters
"Can I block the output to console completely, meaning I would only set output to a log file."
Yes, set the log level, filter or handler in a configuration file
"The entire output is in red, can I set the output to be in different colors according to the level?"
This is specific to Netbeans which I don't personally use so I can't answer that.
Personally I prefer SLF4J with Logback over JUL...
Upvotes: 1