2 Minutes To Code (β Version)

Log4j - 2 minute tutorial

How to make log files rotate per minute or hour programmatically

		package com.techfundaes.log4j;

		import org.apache.log4j.Appender;
		import org.apache.log4j.ConsoleAppender;
		import org.apache.log4j.Layout;
		import org.apache.log4j.Logger;
		import org.apache.log4j.PatternLayout;

		public class ProgrammaticConfigConsole
		{
			public static void main(String[] args)
			{
				Logger logger = Logger.getLogger(ProgrammaticConfigConsole.class);
				Layout layout = new PatternLayout("%d [%t] %-5p (%F:%L) - %m%n");
				Appender appender = new ConsoleAppender(layout);
				logger.addAppender(appender);
				logger.info("Logged this message!!!");
			}
		}