You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2014/01/28 15:32:39 UTC

[jira] [Updated] (LOG4J2-520) RollingRandomAccessFile with Async Appender skip logs

     [ https://issues.apache.org/jira/browse/LOG4J2-520?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Remko Popma updated LOG4J2-520:
-------------------------------

    Description: 
I have written a sample code which will write DEBUG, INFO , WARN logs in a single flile, I have written a logs in FOR loop printing numbers from 1 to 99.
sometime it print numbers incomplete sequence, like 1 to 67, 1 to 89 etc.

log4j2.xml
{code}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
	<Appenders>
		<RollingRandomAccessFile name="RollingRandomAccessFile"
			fileName="logs/app.log" filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log"
			immediateFlush="false" append="true" ignoreExceptions="false">
			<PatternLayout>
				<Pattern>%d %-5p [%t] (%F:%L) - %m%n</Pattern>
			</PatternLayout>
			<Policies>
				<TimeBasedTriggeringPolicy />
				<SizeBasedTriggeringPolicy size="100KB"/>
			</Policies>
		</RollingRandomAccessFile>
		<Async name="ASYNC" includeLocation="true">
			<AppenderRef ref="RollingRandomAccessFile" />
		</Async>
	</Appenders>
	<Loggers>
		<Root level="debug" includeLocation="true">
			<AppenderRef ref="ASYNC" />
		</Root>
	</Loggers>
</Configuration>
{code}

Sample Java Code

{code}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggerUtil {
	public static Logger logger = LoggerFactory.getLogger(LoggerUtil.class);
	public static void main(String[] args) {
		System.out.println("start");
		logger.debug("debug log");
		logger.info("info log");
		logger.error("error log");
		for(int i = 0; i < 99; i++) {
			logger.warn("{}",i);
			System.out.println("I : - " + i);
		}
		logger.error("finish printing logs");
		System.out.println("end");		
	}
}
{code}


  was:
I have written a sample code which will write DEBUG, INFO , WARN logs in a single flile, I have written a logs in FOR loop printing numbers from 1 to 99.
sometime it print numbers incomplete sequence, like 1 to 67, 1 to 89 etc.

log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
	<Appenders>
		<RollingRandomAccessFile name="RollingRandomAccessFile"
			fileName="logs/app.log" filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log"
			immediateFlush="false" append="true" ignoreExceptions="false">
			<PatternLayout>
				<Pattern>%d %-5p [%t] (%F:%L) - %m%n</Pattern>
			</PatternLayout>
			<Policies>
				<TimeBasedTriggeringPolicy />
				<SizeBasedTriggeringPolicy size="100KB"/>
			</Policies>
		</RollingRandomAccessFile>
		<Async name="ASYNC" includeLocation="true">
			<AppenderRef ref="RollingRandomAccessFile" />
		</Async>
	</Appenders>
	<Loggers>
		<Root level="debug" includeLocation="true">
			<AppenderRef ref="ASYNC" />
		</Root>
	</Loggers>
</Configuration>


Sample Java Code

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggerUtil {
	public static Logger logger = LoggerFactory.getLogger(LoggerUtil.class);
	public static void main(String[] args) {
		System.out.println("start");
		logger.debug("debug log");
		logger.info("info log");
		logger.error("error log");
		for(int i = 0; i < 99; i++) {
			logger.warn("{}",i);
			System.out.println("I : - " + i);
		}
		logger.error("finish printing logs");
		System.out.println("end");
		
	}
}



> RollingRandomAccessFile with Async Appender skip logs
> -----------------------------------------------------
>
>                 Key: LOG4J2-520
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-520
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.0-beta9
>         Environment: JDK 1.6, Eclipse
>            Reporter: JavaTech
>            Assignee: Remko Popma
>
> I have written a sample code which will write DEBUG, INFO , WARN logs in a single flile, I have written a logs in FOR loop printing numbers from 1 to 99.
> sometime it print numbers incomplete sequence, like 1 to 67, 1 to 89 etc.
> log4j2.xml
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration>
> 	<Appenders>
> 		<RollingRandomAccessFile name="RollingRandomAccessFile"
> 			fileName="logs/app.log" filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log"
> 			immediateFlush="false" append="true" ignoreExceptions="false">
> 			<PatternLayout>
> 				<Pattern>%d %-5p [%t] (%F:%L) - %m%n</Pattern>
> 			</PatternLayout>
> 			<Policies>
> 				<TimeBasedTriggeringPolicy />
> 				<SizeBasedTriggeringPolicy size="100KB"/>
> 			</Policies>
> 		</RollingRandomAccessFile>
> 		<Async name="ASYNC" includeLocation="true">
> 			<AppenderRef ref="RollingRandomAccessFile" />
> 		</Async>
> 	</Appenders>
> 	<Loggers>
> 		<Root level="debug" includeLocation="true">
> 			<AppenderRef ref="ASYNC" />
> 		</Root>
> 	</Loggers>
> </Configuration>
> {code}
> Sample Java Code
> {code}
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
> public class LoggerUtil {
> 	public static Logger logger = LoggerFactory.getLogger(LoggerUtil.class);
> 	public static void main(String[] args) {
> 		System.out.println("start");
> 		logger.debug("debug log");
> 		logger.info("info log");
> 		logger.error("error log");
> 		for(int i = 0; i < 99; i++) {
> 			logger.warn("{}",i);
> 			System.out.println("I : - " + i);
> 		}
> 		logger.error("finish printing logs");
> 		System.out.println("end");		
> 	}
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org