2014年7月,log4j 2.0在日志框架领域革命性地引入了异步记录器,相比于同步记录器将吞吐率提升了6至68倍。这些结果可能令人影响深刻,但日志框架的性能损耗仍然占据了部分高吞吐率、低延时应用响应时间的很大一部分,这常常导致开发者在部署时排除日志框架。对于高性能应用程序进行微调以避免垃圾回收导致的暂停能够达到非常好的效果,log4j团队断定这些性能提升能够带来更多的用户。
http://logging.apache.org/log4j/2.x/manual/async.html
http://logging.apache.org/log4j/2.x/articles.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| <Configuration monitorInterval="3600" shutdownHook="disable">
<properties> <property name="LOG_HOME">${sys:user.home}</property> <property name="LOG_FILE_SIZE">100 MB</property> <property name="SERVER_NAME">aidijing</property> <property name="OUTPUT_LOG_LEVEL">DEBUG</property> </properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT" follow="true" > <PatternLayout pattern="[%X{userId}] [%X{userName}] %d{yyyy-MM-dd HH:mm:ss SSS} [%p] [%t] %c.%M(%L) | %m%n"/> </Console>
<RollingRandomAccessFile name="RandomAccessFile" fileName="${LOG_HOME}/applogs/${SERVER_NAME}.app.log" filePattern="${LOG_HOME}/applogs/${SERVER_NAME}.$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log" immediateFlush="false" append="false" > <PatternLayout> <Pattern>%X %d{yyyy-MM-dd HH:mm:ss SSS} [%p] [%t] %c.%M(%L) | %m%n</Pattern> </PatternLayout>
<Policies> <TimeBasedTriggeringPolicy interval="1" modulate="true"/> <SizeBasedTriggeringPolicy size="${LOG_FILE_SIZE}"/> </Policies> <DefaultRolloverStrategy fileIndex="max" max="20"/> </RollingRandomAccessFile>
</Appenders>
<Loggers>
<logger name="org.mybatis" level="info" /> <logger name="org.springframework" level="info" /> <logger name="com.alibaba.druid" level="info"/>
<AsyncLogger name="com.aidijing" level="debug" includeLocation="true" additivity="false"> <AppenderRef ref="RandomAccessFile"/> <AppenderRef ref="Console"/> </AsyncLogger>
<Root level="debug" includeLocation="true"> <AppenderRef ref="Console"/> <AppenderRef ref="RandomAccessFile"/> </Root> </Loggers>
</Configuration>
|