# file: Collect messages from text files

Collects log messages from plain-text files, for example, from the logfiles of an Apache webserver. If you want to use [wildcards in the filename, use the `wildcard-file()` source](../../docs/axosyslog-core/chapter-sources/configuring-sources-wildcard-file/index.md).

The AxoSyslog application notices if a file is renamed or replaced with a new file, so it can correctly follow the file even if logrotation is used. When AxoSyslog is restarted, it records the position of the last sent log message in the `/opt/syslog-ng/var/syslog-ng.persist/var/lib/syslog-ng/syslog-ng.persist` file, and continues to send messages from this position after the restart.

The file driver has a single required parameter specifying the file to open. If you want to use [wildcards in the filename, use the `wildcard-file()` source](../../docs/axosyslog-core/chapter-sources/configuring-sources-wildcard-file/index.md). For the list of available optional parameters, see [file() source options](../../docs/axosyslog-core/chapter-sources/configuring-sources-file/reference-source-file/index.md).

## Declaration:
```
       file("filename");
    
```

## Example: Using the file() driver
```
       source s_file {
            file("/var/log/messages");
        };
    
```

## Example: Tailing files

The following source checks the `access.log` file every second for new messages.
```
 
       source s_tail {
            file("/var/log/apache/access.log" follow-freq(1) flags(no-parse));
        };
    
```

Note If the message does not have a proper syslog header, AxoSyslog treats messages received from files as sent by the `kern` facility. Use the `default-facility()` and `default-priority()` options in the source definition to assign a different facility if needed. 

* * *

[Notes on reading kernel messages](../../docs/axosyslog-core/chapter-sources/configuring-sources-file/kernel-messages/index.md)

[file() source options](../../docs/axosyslog-core/chapter-sources/configuring-sources-file/reference-source-file/index.md)

Last modified May 8, 2026: [Marks sources where we do syslog parsing automatically (5b8c29b7)](<https://github.com/axoflow/axosyslog-core-docs/commit/5b8c29b7e7ee800add5a73ae2fe07f4db5115f6c>)