-1

I have a problem with Alfresco. It genarates the log file every day. i want to delete the log file automatically based on date. My server is installed in windows.

can you provide any suggestions on this one.

Rais Alam
  • 6,970
  • 12
  • 53
  • 84
krishna
  • 97
  • 2
  • 4
  • 6

4 Answers4

2

Alfresco is using DailyRollingFileAppender and it is configured to roll log file daily.

###### File appender definition #######
log4j.appender.File=org.apache.log4j.DailyRollingFileAppender
log4j.appender.File.File=alfresco.log
log4j.appender.File.Append=true
log4j.appender.File.DatePattern='.'yyyy-MM-dd
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c] %m%n

Instead you can use RollingFileAppender which rolls log files when it reaches a certain size and with this appender you can also define the maximum number of backups.

log4j.appender.File=org.apache.log4j.RollingFileAppender
log4j.appender.File.MaxBackupIndex=10
...
...

According to the configuration above the appender stores only the last 10 backups. BTW it is also more secure than DailyRollingFileAppender.

According to log4j javadoc;

DailyRollingFileAppender has been observed to exhibit synchronization issues and data loss.

Umut Utkan
  • 648
  • 4
  • 11
  • The part you're leaving out about standard DailyRollingFileAppender: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html _DailyRollingFileAppender has been observed to exhibit synchronization issues and data loss. The log4j extras companion includes alternatives which should be considered for new deployments and which are discussed in the documentation for org.apache.log4j.rolling.RollingFileAppender_ **Apache Extras Companion for Apache log4j** http://logging.apache.org/log4j/companions/extras/download.html – Dan Dar3 Oct 20 '12 at 19:21
1

the best way is to write your own little utility and register it as a "scheduled task" to run at a pre-defined time in the day.
you can register a service too, but i feel that'll be an overkill.

anirvan
  • 4,797
  • 4
  • 32
  • 42
0

I suggest that you decrease your logging level as much as you can. There is a log4j.properties file in each of alfresco's apps (alfresco/WEB-INF/classes/log4j.properties and share/WEB-INF/classes/log4j.properties) - logging is noted to affect the performance of alfresco.

Also, you should be able to disable logging completely.

Zlatko
  • 18,936
  • 14
  • 70
  • 123
-1

Please see http://www.autohotkey.com/forum/topic43254.html Its providing one simple tool to delete logs. Just use it.

Nike
  • 312
  • 1
  • 2
  • 9