diff -Nurw syslog-ng-1.4.14/doc/sgml/syslog-ng.sgml syslog-ng-1.4.14.kvg/doc/sgml/syslog-ng.sgml
--- syslog-ng-1.4.14/doc/sgml/syslog-ng.sgml	Mon Nov  6 10:30:58 2000
+++ syslog-ng-1.4.14.kvg/doc/sgml/syslog-ng.sgml	Fri Feb  1 10:09:51 2002
@@ -885,6 +885,12 @@
 		</entry>
 	      </row>
 	      <row>
+		<entry>WEEKDAY</entry>
+		<entry>
+		  The 3-letter name of the day of week the message was sent, e.g. 'Thu'.
+		</entry>
+	      </row>
+	      <row>
 		<entry>HOUR</entry>
 		<entry>
 		  The hour of day the message was sent.
@@ -1022,6 +1028,23 @@
 		  no
 		</entry>
 	      </row>
+
+	      <row>
+		<entry>remove_if_older()</entry> 
+		<entry>number</entry>
+		<entry>
+		  If set to a value higher than 0, before writing to a file, syslog-ng
+		  checks whether this file is older than the specified amount of days.
+		  If so, it removes the existing file and the line to be written is the
+		  first line in a new file with the same name.
+		  In combination with e.g. the $WEEKDAYS macro, this is can be used
+		  for simple log rotation, in case not all history need to be kept.
+		</entry>
+		<entry>
+		  Do never remove existing files, but append ( = 0).
+		</entry>
+	      </row>
+
 	    </tbody>
 	  </tgroup>
 	</table>
diff -Nurw syslog-ng-1.4.14/src/affile.c syslog-ng-1.4.14.kvg/src/affile.c
--- syslog-ng-1.4.14/src/affile.c	Wed Jul 11 16:08:16 2001
+++ syslog-ng-1.4.14.kvg/src/affile.c	Fri Feb  1 09:56:30 2002
@@ -42,6 +42,7 @@
 #include <grp.h>
 #include <unistd.h>
 #include <stdio.h>
+#include <time.h>
 #include "syslog-names.h"
 
 #include "affile.c.x"
@@ -201,7 +202,20 @@
   	if (self->owner->flags & AFFILE_PIPE)
   		flags = O_RDWR | O_NOCTTY | O_NONBLOCK;
   	else
-	  	flags = O_WRONLY | O_CREAT | O_APPEND |O_NOCTTY | O_NONBLOCK;
+        	flags = O_WRONLY | O_APPEND | O_CREAT | O_NOCTTY | O_NONBLOCK;
+
+	if (self->owner->remove_if_older > 0) {
+        	/* remove (=unlink) if file is more than XXX days old */
+        	struct stat  mystat;
+        	time_t  mycurrenttime = time(NULL);
+        	if (stat(self->expanded_fname->data, &mystat) == 0) {
+                	if ((mycurrenttime-mystat.st_mtime) >=
+                    	(24*60*60*(self->owner->remove_if_older))) {
+                        	unlink(self->expanded_fname->data);
+                	}
+        	}
+	}
+
 	if (do_open_file(self->expanded_fname, flags, 
 	                 self->owner->uid, self->owner->gid, self->owner->perm, 
 	                 self->owner->dir_uid, self->owner->dir_gid, self->owner->dir_perm,
@@ -264,6 +278,7 @@
 	 (dir_gid . int)
 	 (dir_perm . int)
          (flags simple int)
+         (remove_if_older . int)
 	 (sync_freq simple UINT32)
 	 (template_fname string)
 	 (writers object affile_dest_writer)
@@ -363,6 +378,17 @@
 	self->flags = set_flags(self->flags, AFFILE_CREATE_DIRS, AFFILE_CREATE_DIRS_SHIFT, enable);
 }
 
+void affile_set_remove_if_older(struct log_dest_driver *c, int days)
+{
+	CAST(affile_dest, self, c);
+
+	if (days < 0) {
+		werror("Warning: the days before removal parameter is negative, disables option\n");
+		days = -1;
+	}
+	self->remove_if_older = days;
+}
+
 #define MAX_MACRO_ARGS        32
 #define MAX_EXPANDED_MACRO    1024
 
@@ -625,6 +651,7 @@
 	self->perm = -1;
 	self->dir_uid = self->dir_gid = -1;
 	self->dir_perm = -1;
+	self->remove_if_older = -1;
 	self->template_fname = c_format_cstring("%z", name);
 	if (strchr(name, '$') == NULL)
 		flags |= AFFILE_NO_EXPAND;
diff -Nurw syslog-ng-1.4.14/src/affile.c.x syslog-ng-1.4.14.kvg/src/affile.c.x
--- syslog-ng-1.4.14/src/affile.c.x	Wed Jul 11 16:08:37 2001
+++ syslog-ng-1.4.14.kvg/src/affile.c.x	Fri Feb  1 10:00:03 2002
@@ -109,6 +109,7 @@
   int dir_uid;
   int dir_gid;
   int dir_perm;
+  int remove_if_older;
   int flags;
   UINT32 sync_freq;
   struct ol_string *template_fname;
diff -Nurw syslog-ng-1.4.14/src/affile.h syslog-ng-1.4.14.kvg/src/affile.h
--- syslog-ng-1.4.14/src/affile.h	Sun Feb 25 13:30:22 2001
+++ syslog-ng-1.4.14.kvg/src/affile.h	Fri Feb  1 00:50:37 2002
@@ -55,6 +55,7 @@
 void affile_set_dir_group(struct log_dest_driver *c, char *group);
 void affile_set_dir_perm(struct log_dest_driver *c, int perm);
 void affile_set_create_dirs(struct log_dest_driver *c, int enable);
+void affile_set_remove_if_older(struct log_dest_driver *c, int days);
 
 struct log_source_driver *make_affile_source(const char *name, int flags);
 struct log_dest_driver *make_affile_dest(const char *name, int flags);
diff -Nurw syslog-ng-1.4.14/src/cfg-grammar.y syslog-ng-1.4.14.kvg/src/cfg-grammar.y
--- syslog-ng-1.4.14/src/cfg-grammar.y	Sun Feb 25 13:30:22 2001
+++ syslog-ng-1.4.14.kvg/src/cfg-grammar.y	Fri Feb  1 00:50:37 2002
@@ -71,6 +71,7 @@
 %token KW_OWNER KW_GROUP KW_PERM KW_KEEP_ALIVE KW_MAX_CONNECTIONS
 %token KW_LOCALIP KW_IP KW_LOCALPORT KW_PORT KW_DESTPORT 
 %token KW_COMPRESS KW_MAC KW_AUTH KW_ENCRYPT
+%token KW_REMOVE_IF_OLDER
 
 /* filter items*/
 %token KW_FACILITY KW_LEVEL KW_PROGRAM KW_HOST KW_MATCH
@@ -361,6 +362,7 @@
 	| KW_DIR_GROUP '(' string ')'		{ affile_set_dir_group(last_dest_driver, $3); free($3); }
 	| KW_DIR_PERM '(' NUMBER ')'		{ affile_set_dir_perm(last_dest_driver, $3); }
 	| KW_CREATE_DIRS '(' yesno ')'		{ affile_set_create_dirs(last_dest_driver, $3); }
+	| KW_REMOVE_IF_OLDER '(' NUMBER ')'	{ affile_set_remove_if_older(last_dest_driver, $3); }
 	;
 
 dest_afpipe
diff -Nurw syslog-ng-1.4.14/src/cfg-lex.l syslog-ng-1.4.14.kvg/src/cfg-lex.l
--- syslog-ng-1.4.14/src/cfg-lex.l	Sun Feb 25 13:30:22 2001
+++ syslog-ng-1.4.14.kvg/src/cfg-lex.l	Fri Feb  1 00:50:37 2002
@@ -83,6 +83,7 @@
 	{ "allow",		KW_ALLOW },
 	{ "deny",		KW_DENY },
 	{ "compress",		KW_COMPRESS },
+	{ "remove_if_older",	KW_REMOVE_IF_OLDER },
        
 	/* source or destination items */
 	{ "file",		KW_FILE },
