• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Logging level question

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found it ... could set the loglevel on the consoleHandler
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic