[ https://issues.apache.org/jira/browse/LOG4J2-2886?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17186470#comment-17186470 ]
Luigi Pellico edited comment on LOG4J2-2886 at 8/28/20, 6:42 PM: ----------------------------------------------------------------- Ok, considering the large number of logs I produce I would proceed in this way: # set status=DEBUG # set monitoringInterval=60 # set all rolling on 1MB (<SizeBasedTriggeringPolicy size="1 MB"/>) These parameters allow me to capture what you need? If I set a time interval too low I have a system out that becomes huge. Do I feel this way? No: hangs file is the rolled file and this hangs file cause, over time, disk full space. ex. {code:java} <RollingRandomAccessFile name="bp-service-trace" fileName="${micro-service-log-path}/bp-micro-service-trace.log" filePattern="${micro-service-log-path}/archive/bp-micro-service-trace-%d{yyyy-MM-dd}-%i.trace.gz"> <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/> <!-- Log pattern layout --> <PatternLayout> <pattern>|%X{traceID}|%m%n</pattern> </PatternLayout> <!-- File size policy --> <Policies> <TimeBasedTriggeringPolicy /> <SizeBasedTriggeringPolicy size="3 MB"/> </Policies> <DefaultRolloverStrategy> <Delete basePath="${micro-service-trace-path}/archive/" maxDepth="2"> <IfFileName glob="bp-micro-service-trace-*.trace.gz" /> <IfLastModified age="7d" /> </Delete> </DefaultRolloverStrategy> </RollingRandomAccessFile> {code} bp-micro-service-trace.log rolling every 3MB (<SizeBasedTriggeringPolicy size="3 MB"/>) then (when reaches 3 mb) log4j (I suppose it does this): # move bp-micro-service-trace.log on /archive/ # compress it in /archive/bp-micro-service-trace-%d\{yyyy-MM-dd}-%i.trace.gz # delete file moved (/archive/bp-micro-service-trace.log) This last file is hangs file. All this files that ramains in hangs during rolling (in /archive) cause full disk space over time. Only restart was remove file *.log from archive directory. ... I don't know whether to be happy with having won or worried! :) was (Author: luigi.pellico): Ok, considering the large number of logs I produce I would proceed in this way: # set status=DEBUG # set monitoringInterval=60 # set all rolling on 1MB (<SizeBasedTriggeringPolicy size="1 MB"/>) These parameters allow me to capture what you need? If I set a time interval too low I have a system out that becomes huge. Do I feel this way? No: hangs file is the rolled file and this hangs file cause, over time, disk full space. ex. {code:java} <RollingRandomAccessFile name="bp-service-trace" fileName="${micro-service-log-path}/bp-micro-service-trace.log" filePattern="${micro-service-log-path}/archive/bp-micro-service-trace-%d{yyyy-MM-dd}-%i.trace.gz"> <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/> <!-- Log pattern layout --> <PatternLayout> <pattern>|%X{traceID}|%m%n</pattern> </PatternLayout> <!-- File size policy --> <Policies> <TimeBasedTriggeringPolicy /> <SizeBasedTriggeringPolicy size="3 MB"/> </Policies> <DefaultRolloverStrategy> <Delete basePath="${micro-service-trace-path}/archive/" maxDepth="2"> <IfFileName glob="bp-micro-service-trace-*.trace.gz" /> <IfLastModified age="7d" /> </Delete> </DefaultRolloverStrategy> </RollingRandomAccessFile> {code} bp-micro-service-trace.log rolling every 3MB (<SizeBasedTriggeringPolicy size="3 MB"/>) then (when reaches 3 mb) log4j (I suppose it does this): # move bp-micro-service-trace.log on /archive/ # compress it in /archive/bp-micro-service-trace-%d\{yyyy-MM-dd}-%i.trace.gz # delete file moved (/archive/bp-micro-service-trace.log) This last file is hangs file. All this files that ramins in hangs during rolling (in /archive) cause full disk space over time. Only restart was remove file *.log from archive directory ... I don't know whether to be happy with having won or worried! :) > File Hangs when Rolling file on log4j > ------------------------------------- > > Key: LOG4J2-2886 > URL: https://issues.apache.org/jira/browse/LOG4J2-2886 > Project: Log4j 2 > Issue Type: Bug > Components: Appenders > Affects Versions: 2.9.1 > Environment: Java 8, log4j 2.9.1, Linux radhat 7, Websphere > Application Server 8.5.5.14 > Reporter: Luigi Pellico > Priority: Major > Attachments: SystemOut_20.08.21_18.31.16.log, > SystemOut_20.08.21_18.33.47.log, image-2020-08-21-22-16-04-742.png, > log4j2.xml, lsof_20200821.txt > > > expose my question > Enviroment: > Java 8, log4j 2.9.1, Linux radhat 7, Websphere Application Server 8.5.5.14 > Problem: > When rolling file log the rolled file hangs. Only Websphere Application > Server restar resolve problem and empty file system from hangs file. > This problem cause full disk space on log partition. > try: > try to change appender mode but problem remain try solution on this similar > question: > * [How can I get log4j to delete old rotating log > files?|https://stackoverflow.com/questions/1050256/how-can-i-get-log4j-to-delete-old-rotating-log-files] > * [Log4j2 Rolled Files that are deleted are still open and disk space not > freed|https://stackoverflow.com/questions/27855869/log4j2-rolled-files-that-are-deleted-are-still-open-and-disk-space-not-freed] > Other info: > File are deleted but space is not free: > {{$ /usr/sbin/lsof | grep deleted}} > java 114u REG 253,12 191 8814849 /var/log/archive/<filename>.log (deleted) > This is log4j configuration: > {code:java} > <RollingRandomAccessFile name="<filename>" fileName="/<filename>.log" > filePattern="/archive/<filename>%d {yyyy-MM-dd} %i.log.gz"> > <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/> > <!- Log pattern layout > -><PatternLayout><pattern>|%X{traceID}|%m%n</pattern></PatternLayout> > <!- File size policy --> > <Policies> > <TimeBasedTriggeringPolicy /> > <SizeBasedTriggeringPolicy size="150 MB"/> > </Policies> > <DefaultRolloverStrategy> > <Delete basePath="/archive/" maxDepth="2"> > <IfFileName glob="<filename>*.log.gz" /> > <IfLastModified age="7d" /> > </Delete> > </DefaultRolloverStrategy> > </RollingRandomAccessFile>{code} -- This message was sent by Atlassian Jira (v8.3.4#803005)