import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class SampleApp { private static final Log logger = LogFactory.getLog(SampleApp.class); public static void main(String[] args) { logger.info("SampleApp started"); // some code here... logger.warn("Something went wrong"); } }
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.impl.SimpleLog; import org.apache.commons.logging.impl.SimpleLogConfigurator; public class SampleApp { static { // configure logger programmatically SimpleLogConfigurator.configure(new SimpleLog(), SimpleLog.LOG_LEVEL_INFO); } private static final Log logger = LogFactory.getLog(SampleApp.class); public static void main(String[] args) { logger.info("SampleApp started"); // some code here... logger.warn("Something went wrong"); } }This example shows how to customize the log configuration by programmatically configuring the SimpleLog instance. Overall, the org.apache.commons.logging Log package library is a flexible and easy-to-use logging framework that can be used in a wide range of Java applications.