日志似乎会正常滚动和存档,但在指定的触发器时间或附近,我注意到tomcat catalina.out中出现了一个异常(有时一次,其他时候它以每秒1次的速度泛洪日志)。感谢任何帮助。
2016-10-27 16:11:24,002 Log4j2-Log4j2Scheduled-2 ERROR Error running command java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/impl/Log4jLogEvent$Builder
at org.apache.logging.log4j.core.appender.rolling.PatternProcessor.formatFileName(PatternProcessor.java:234)
at org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy.purgeAscending(DefaultRolloverStrategy.java:323)
at org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy.purge(DefaultRolloverStrategy.java:306)
at org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy.rollover(DefaultRolloverStrategy.java:524)
at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:220)
at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.rollover(RollingFileManager.java:155)
at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.rollover(CronTriggeringPolicy.java:127)
at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.access$100(CronTriggeringPolicy.java:40)
at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy$CronTrigger.run(CronTriggeringPolicy.java:144)
at org.apache.logging.log4j.core.config.ConfigurationScheduler$CronRunnable.run(ConfigurationScheduler.java:180)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
The web application [my-services] appears to have started a thread named [Log4j2-Log4j2Scheduled-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info" name="MyLog" packages="">
<Properties>
<Property name="baseDir">/var/log/tomcat</Property>
<Property name="appName">MyLog</Property>
</Properties>
<Appenders>
<RollingFile name="RollingFile" fileName="${baseDir}/${appName}.log" immediateFlush="true"
filePattern="${baseDir}/$${date:yyyy}/$${date:MM}/${appName}-$${date:yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="%highlight{%d %p{INFO=INFO_,WARN=WARN_} %c{3.} (%M:%L) [%t] %m%n%ex}{FATAL=Magenta,TRACE=Normal White}" />
<CronTriggeringPolicy schedule="0 0 0 * * ?"/>
<DefaultRolloverStrategy>
<Delete basePath="${baseDir}" maxDepth="2">
<IfFileName glob="*/${appName}-*log.gz" />
<IfLastModified age="90d" />
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%highlight{%d %p{INFO=INFO_,WARN=WARN_} %c{3.} (%M:%L) [%t] %m%n%ex}{FATAL=Magenta,TRACE=Normal White}" />
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="RollingFile"/>
<!--<AppenderRef ref="Console"/>-->
</Root>
</Loggers>
</Configuration>
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1">
<display-name>My Services</display-name>
<!-- log4j2 configuration file -->
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>log4j2.xml</param-value>
</context-param>
<!-- my servlet -->
<servlet>
<servlet-name>my-services</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>my.package, com.fasterxml.jackson.jaxrs.json</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>my-services</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- version properties -->
<jersey.version>2.23.1</jersey.version>
<jackson.version>2.7.2</jackson.version>
<spring.version>4.1.6.RELEASE</spring.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>${spring.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.6.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- Jersey and Jackson -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<!-- Jersey w/Tomcat 8 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
</dependencies>
当Tomcat webapps关闭时,Tomcat webapps中的lo4j2 2.6.2泄漏线程存在已知问题。我怀疑您看到ClassNotFoundExceptions是因为一个孤立线程试图加载类。这是特别可能的,因为您正在使用CronTriggeringPolicy强制在午夜滚动日志,但在策略执行之前重新启动webapp。
lo4j2 2.7中发布了一个修复程序。尝试颠簸你的版本。
据我所知,log4j2中的RollingFileAppender不会在指定的时间(比方说-在一小时结束时)回滚,而是在超过时间阈值后到达的第一个日志事件时回滚。 有没有一种方法可以触发一个事件,一方面会导致文件滚动,另一方面不会附加到日志中(或者会附加一些无关紧要的东西,比如空字符串)?
在用户任务上应用边界计时器事件,在服务任务上添加java类属性,但当计时器到期触发异常列表时,会抛出,即无法找到分配给服务任务的类。类存在于类路径上。activiti配置中还启用了asyncExecutorActivate属性 这里有一个代码 例外 Bean初始化
这是我的log4j2.xml 我想实现每小时滚动的每日滚动文件,到目前为止,我还没有能够产生适当格式的日志,正如我所记得的,间隔参数似乎是按天而不是按小时递增。 我想实现这一点: 路由器。日志-- 路由器。日志2014-06-20-00 路由器。日志2014-06-20-01 ... 路由器。日志2014-06-20-23 路由器。日志2014-06-21-00 ... 相反,我做到了这一点: r
Im使用具有以下依赖关系的log4j2: 编辑:我尝试添加includeLocation=“true”,但结果仍然相同 谢谢
环境:spring boot 1.5.9。发布spring-boot-starter-log4j2(是Log4j 2.7版本) 所有输出信息大小为9KB,包括所有spring boot输出 这是我的log4j2.xml配置: 所以,问题是: 当我激活Spring启动并通过引发异常进行测试时,log4j2打印了一些东西,并触发了我设计的异常,然后Spring启动无法停止,因为log4j2内存泄漏。
我使用的是Spring3.0.5和Hibernate3.6。在我的项目中,有一个场景,我必须回滚在抛出的任何异常或错误发生的事务。这是示例代码,除了当我抛出异常时事务不会回滚之外,一切都很好,但是如果抛出任何异常,比如mysql.IntegrityConstraintException,那么事务会回滚,为什么在我的情况下没有发生这种情况? hibernate.cfg 因此,正如我所说,我的问题是,