Your tasks for this assignment are to:
How you choose to incorporate logging into your program is up toyou, subject to the constraints noted below. The LearningMaterials page references several resources that you mightfind useful as you begin thinking about how to implement logging inyour program.
Constraints for generating logs:
Constraints for parsing logs:
Please submit:
________________________________
That is the instructions for the assignment. I already have thiscode but it is not working. Can anyone help?
testLogging.java
import java.util.logging.Level;
public class testLogging { public static voidmain(String[] args) { try{ testingLog testLog = newtestingLog("log.txt"); testLog.logger.setLevel(Level.WARNING); testLog.logger.info("Info Message"); testLog.logger.warning("WarningMessage"); testLog.logger.severe("SevereMessage"); } catch(Exception e) { } }}
testingLog.java
import java.io.File;import java.io.IOException;import java.util.logging.FileHandler;import java.util.logging.Logger;import java.util.logging.SimpleFormatter;
public class testingLog { public Logger logger; FileHandler testFile; public Log(String file_name) throwsSecurityException, IOException { File fileTest = newFile(file_name); if(!fileTest.exists()) { fileTest.createNewFile(); } testFile = newFileHandler(file_name, true); logger =Logger.getLogger("Test"); logger.addHandler(testFile); SimpleFormatter logFormatter= new SimpleFormatter(); testFile.setFormatter(logFormatter); }
}
Your tasks for this assignment are to: How you choose to incorporate logging into your program is up to you, subject to
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am