Hi,

I am Rui from China.

We use both of KafkaAppender (with a AsyncAppender wrapper) and FileAppender of 
log4j2 with version 2.6.2 in the application.

Here is the scenaria, when kafka cluster down and stop service, the application 
will slow down and wait for given timeout (request.timeout.ms)

to response finally (The bufferSize of AsyncKafka is reached).

I am wondering if there is any solution that the fileAppender can always work 
normally without any performance issue which affected

by KafkaAppender. In other words, the KafkaAppender can "DISCARD" the logs when 
kafka cluster down while the application

can output the logs by FileAppender.


Thanks,
Rui

<configuration>
    <Properties>
        <Property name="kafka-servers">xx.xxx.xxx.xxx:xxxx</Property>
        <Property name="log-path">/applog/logging</Property>
    </Properties>

    <Appenders>
    
        <Kafka name="Kafka" topic="test_test" ignoreExceptions="false">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%t] %c{1} - %msg%n"/>
            <Property name="bootstrap.servers">${kafka-servers}</Property>
            <Property name="request.timeout.ms">1000</Property>
            <Property name="max.block.ms">30000</Property>
            <Property name="retries">0</Property>
            <Property name="acks">0</Property>
        </Kafka>
		
		<Async name="AsyncKafka" bufferSize="128">
			<AppenderRef ref="Kafka"/>
		</Async>
       
        <RollingFile name="RollingFile" fileName="${log-path}/logging.log"
                     filePattern="${log-path}/$${date:yyyy-MM}/logging-%d{MM-dd-yyyy}-%i.log.gz" >           
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%t] %c{1} - %msg%n"/>
            <Policies>               
                <TimeBasedTriggeringPolicy /> 
                <SizeBasedTriggeringPolicy size="20 MB" />
            </Policies>
            <DefaultRolloverStrategy max="100"/>
        </RollingFile>
		
        <Console name="Console" target="SYSTEM_OUT" ignoreExceptions="false">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%t] %c{1} - %msg%n"/>
        </Console>
		
    </Appenders>

    <Loggers>
    	<Root level="INFO">
    		<AppenderRef ref="AsyncKafka"/> 
    		<AppenderRef ref="Console"/>
    		<AppenderRef ref="RollingFile"/>
    	</Root>
    </Loggers>
</configuration>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to