aspose file tools*
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
Author

Logging level question

Wim Monden
Greenhorn

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?

thanks

==================================

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");
myLogger.addHandler(myFileHandler);
myLogger.setLevel(Level.ALL);

/* 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");

myFileHandler.close();
}
}
Wim Monden
Greenhorn

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
 
Similar Threads
Using java.util.logging.Logger in a multiThreaded application
General uneasy feeling about java logging...... or maybe it's just too much eggnog
reformatting standard out in a logging class
RAD6/WAS6 Logging config..
java.util.Logging configuration...