log4j2

数据库连接池Druid使用总结(结合各位大牛总结的)

会有一股神秘感。 提交于 2019-12-17 06:50:53
根据综合性能,可靠性,稳定性,扩展性,易用性等因素替换成最优的 数据库 连接池。 Druid:druid-1.0.29 数据库 Mysql.5.6.17 替换 目标: 替换掉C3P0,用 druid来替换 替换原因: 1、性能方面 hikariCP>druid>tomcat-jdbc>dbcp>c3p0 。hikariCP的高性能得益于最大限度的避免锁竞争。 2、druid功能最为全面,sql拦截等功能,统计数据较为全面,具有良好的扩展性。 3、综合性能,扩展性等方面,可考虑使用druid或者hikariCP连接池 ,比较方便对jdbc接口进行监控跟踪等。 4、可开启prepareStatement缓存,对性能会有大概20%的提升。 psCache是connection私有的,所以不存在线程竞争的问题,开启pscache不会存在竞争的性能损耗。 psCache的key为prepare执行的sql和catalog等,value对应的为prepareStatement对象。开启缓存主要是减少了解析sql的开销。 5、 3p0历史悠久,代码及其复杂,不利于维护。并且存在deadlock的潜在风险。 6、Druid可以打印SQL,慢查询方面的日志 Druid 参数 配置参数 缺省值 游戏服设置的值 参数说明 initialSize 0 4 初始化连接数量 minIdle 0 4

How to customize log4j2 RollingFileAppender?

拟墨画扇 提交于 2019-12-17 06:16:32
问题 We use log4j 1.2.x for logging in our product and are looking to migrate to log4j 2.x in near future. One of the functionality we have implemented is to log the system information and other important parameters on every new roll-over logfile that gets generated. The way we implemented in log4j 1.2.x is that we have extended RollingFileAppender class of log4j and have overridden the rollOver() method, below is the part snippet of the implementation @Override public void rollOver() { super

Error when using LogManager (l4j2) with Java 8 (java.lang.reflect.AnnotatedElement cannot be resolved)

回眸只為那壹抹淺笑 提交于 2019-12-16 19:55:59
问题 I just encountered a strange error when switching the JDK version of a new Project of mine from 7u45 to 8u20. A harmless LogManager declaration at the beginning of my class is being refused with the following error: The type java.lang.reflect.AnnotatedElement cannot be resolved. It is indirectly referenced from required .class files This is the code: public class Class1 { private static Logger log = LogManager.getLogger(Class1.class); ... Eclipse proposes me to configure the build path, but I

Why does the log4j2's ${web:rootDir} web lookup cause issues at the deployment in weblogic 12c?

醉酒当歌 提交于 2019-12-14 03:58:22
问题 The log4j2's web lookup - ${web:rootDir} seems to cause problems on weblogic 12c deployment. I suspect that the log4j2 web-lookup plugin is not initialized when weblogic requests the logger at the start of deployment and is unable to create the file. What I've done - Added slf4j in weblogic preferred packages of weblogic.xml. log4j-web dependency is present in classpath. 3.web.xml contains following:- <context-param> <param-name>isLog4jAutoInitializationDisabled</param-name> <param-value>true

slf4j-log4j converts objects to string before passing to Asynchronus logger

▼魔方 西西 提交于 2019-12-14 01:17:05
问题 I'm looking to log the request and response to a web service. I'm using slf4j with underlying log4j2 implementation. My logger statement looks like the below. LOGGER.info("{}",new CustomObject(request,response,param1,param2)); I have implemented the toString methods in all the necessary objects and in the CustomObject class to log all attributes of that object. I see that the toString method of the CustomObject is called before it passes the log message to the Asynch logger. Is there anyway

log4j2.xml configuration from file for mule applications in mule 3.6.2

陌路散爱 提交于 2019-12-14 00:27:43
问题 How can I get the configuration from a specific file like '/opt/applications/app1/log/config/log4j2.xml' for a mule application in mule 3.6.2. The common way is to get the configuration from a config file log4j2.xml which is stored in the resource folder, we need to read this configuration file from other external path. 回答1: By default, Mule use its own log4j2 file for logging. To read log4j2.xml configuration file from external path, add the next beans in your file Application Context, For

Wildfly 10.0.0 Final does not Log boot logs for deployed application WAR

旧时模样 提交于 2019-12-13 21:22:51
问题 I have deployed MyApp.EAR and CAS.WAR on wildfly 10.0.0 Final. CAS.WAR uses higher version of Jackson so have used jboss-deployment-structure.xml is used for the same. So CAS.WAR/META-INF/jboss-deployment-structure.xml looks like, <?xml version='1.0' encoding='UTF-8'?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <exclusions> <module name="com.fasterxml.jackson.core.jackson-annotations" /> <module name="com.fasterxml.jackson.core.jackson-core" />

Log4j2.xml configuration file location for EAR

拜拜、爱过 提交于 2019-12-13 19:05:23
问题 I have a Java EE application packaged with ejbs and war. Following is the structure of the EAR: myapp.ear -lib -META-INF -ejbjar1.jar -ejbjar2.jar -mywebapp.war I need to use log4j2 so I have tried to configure it at first from the web.xml by following instructions to initialize Log4j 2 in a web application but when I am creating the Logger in an EJB it is throwing: ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. The

Log4j2 RollingFile appender start archiving after N days?

让人想犯罪 __ 提交于 2019-12-13 17:07:34
问题 This is the conf I am using at the moment: <RollingFile name="RollingFileAppender" fileName="/tmp/test.log" filePattern="/tmp/test-%i.log.gz" ignoreExceptions="false"> <PatternLayout pattern="%m%n" /> <Policies> <SizeBasedTriggeringPolicy size="100 MB" /> </Policies> <DefaultRolloverStrategy max="5" /> </RollingFile> Notice the '.gz' extension that make log4j2 compress the rotated log files. I would like to keep 5 files uncompressed and start compressing only after that. Is there a way to

Log4J2 Log Level precedence

痴心易碎 提交于 2019-12-13 08:07:10
问题 I have the log4j2.xml which is partially configured as: <Loggers> <Root level="debug" includeLocation="true"> <AppenderRef ref="FileInfo" level="info" /> <AppenderRef ref="FileDebug" level="debug" /> </Root> <Logger name="com.mycompany.domain.XYZ" level="TRACE" /> <Logger name="com.mycompany.domain.ABC" level="TRACE" /> </Loggers> However, the TRACE messages doesn't come in either of the File appenders (FileInfo/FileDebug). When I change the FileDebug log level = "TRACE", then TRACE messages