diff --git a/docs/configuration/logging.md b/docs/configuration/logging.md
index a3d176d9e..b0b5a95bf 100644
--- a/docs/configuration/logging.md
+++ b/docs/configuration/logging.md
@@ -87,6 +87,16 @@ log:
file_path: /config/authelia.log
```
+If you include the value `%d` in the filename it will replace this value with a date time indicative of the time
+the logger was initialized in the following format:
+
+`2006-02-01T150405Z`
+
+```yaml
+log:
+ file_path: /config/authelia.%d.log
+```
+
### keep_stdout
type: boolean
diff --git a/internal/logging/logger.go b/internal/logging/logger.go
index 9cd10f121..9b5540cce 100644
--- a/internal/logging/logger.go
+++ b/internal/logging/logger.go
@@ -3,6 +3,8 @@ package logging
import (
"io"
"os"
+ "strings"
+ "time"
logrus_stack "github.com/Gurpartap/logrus-stack"
"github.com/sirupsen/logrus"
@@ -30,7 +32,9 @@ func InitializeLogger(config schema.LogConfiguration, log bool) error {
}
if config.FilePath != "" {
- f, err := os.OpenFile(config.FilePath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
+ filePath := strings.ReplaceAll(config.FilePath, "%d", time.Now().Format("2006-02-01T150405Z"))
+
+ f, err := os.OpenFile(filePath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return err