wood burning stoves 2.0
The moose likes Beginning Java and the fly likes Logging level question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Logging level question" Watch "Logging level question" New topic

Logging level question

Wim Monden

Joined: Oct 14, 2010
Posts: 3
Hello, I've got a little program for logging testing.

I've set the level to ALL. The logging works fine in the logfile. In the console I only get
the logging for SEVERE, WARNING and INFO. Is this done by another logger?



import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

public class TestClass {
public static void main(String[] args) throws IOException {

/* Ensure directory has been created */
new File("logs").mkdir();

/* Get the date to be used in the filename */
DateFormat df = new SimpleDateFormat("yyyyMMddhhmmss");
Date now = new Date();
String date = df.format(now);
/* Set up the filename in the logs directory */
String logFileName = "logs\\testlog-" + date + ".txt";

/* Set up Logger */
FileHandler myFileHandler = new FileHandler(logFileName);
myFileHandler.setFormatter(new SimpleFormatter());
Logger myLogger = Logger.getLogger("MyLogger");

/* Log Messages */
myLogger.log(Level.CONFIG, "Config level");
myLogger.log(Level.INFO, "Info level");
myLogger.log(Level.SEVERE, "Severe level");
myLogger.log(Level.WARNING, "Warning level");
myLogger.log(Level.FINE, "Fine level");
myLogger.log(Level.ALL, "All level");

Wim Monden

Joined: Oct 14, 2010
Posts: 3
Found it ... could set the loglevel on the consoleHandler
I agree. Here's the link: http://aspose.com/file-tools
subject: Logging level question
It's not a secret anymore!