Intro
This example will demonstrates the basic usage simple logging in the Java program.
Example
package com.freesamplecode.java.logging; import java.util.logging.Level; import java.util.logging.Logger; public class CreateSimpleLoggingDemo { public static void main(String[] args){ Logger logger = Logger.getLogger(CreateSimpleLoggingDemo.class.getName()); logger.log(Level.INFO, "This is INFO level message"); logger.log(Level.SEVERE, "This is SEVERE level message"); logger.log(Level.WARNING, "This is WARNING level message"); logger.log(Level.FINE, "This is FINE level message"); } }
Output
Mar 12, 2016 6:46:04 AM com.freesamplecode.java.logging.CreateSimpleLoggingDemo main INFO: This is INFO level message Mar 12, 2016 6:46:07 AM com.freesamplecode.java.logging.CreateSimpleLoggingDemo main SEVERE: This is SEVERE level message Mar 12, 2016 6:46:07 AM com.freesamplecode.java.logging.CreateSimpleLoggingDemo main WARNING: This is WARNING level message
0 comments: