Home > DeveloperSection > Forums > Writing events to log text file using java
Kate Smith
Kate Smith

Total Post:24

Points:168
Posted on    October-05-2013 7:57 AM

 Java Java 
Ratings:


 1 Reply(s)
 814  View(s)
Rate this:

The below line of code I am trying to write the events in a log file but no file is being created and I am also not getting any kind of error at all.

My log class:

public class Logs {
static FileHandler fileTxt;
static SimpleFormatter formatterTxt;
static public void logging() throws IOException {
    Logger logger = Logger.getLogger("");
    logger.setLevel(Level.INFO);
    fileTxt = new FileHandler("c:/SimleTaskEvents.txt");
    formatterTxt = new SimpleFormatter();
    fileTxt.setFormatter(formatterTxt);
    logger.addHandler(fileTxt);
}
}


Hank Greenberg
Hank Greenberg

Total Post:12

Points:84
Posted on    October-05-2013 9:03 AM

You should write to the log first logger.info("my logging line");


Don't want to miss updates? Please click the below button!

Follow MindStick