Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Logging level question

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?



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
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
them good ole boys were drinking whiskey and rye singin' this'll be the day that I die. Drink tiny ad.
Garden Master Course kickstarter
    Bookmark Topic Watch Topic
  • New Topic