Skip to content

Create logfile at startup#310

Open
ne20002 wants to merge 2 commits intofriendica:stablefrom
ne20002:feat/logfile
Open

Create logfile at startup#310
ne20002 wants to merge 2 commits intofriendica:stablefrom
ne20002:feat/logfile

Conversation

@ne20002
Copy link
Collaborator

@ne20002 ne20002 commented Jul 5, 2025

This PR is opened as draft pull request as it may need some discussion and a bit more testing.

As described in #friendica/friendica#15001 the log file is not creatd by friendica when logging is enabled. This PR is an attempt to fix this.

I only had time to test this with the fpm image (which is debian based).

My concerns are:

  • I don't want to just create an empty log file with the current default (which is /var/www/html/friendica.log) as its location in /var/www/html is not really a good idea. I would vote for /var/log/friendica.log as a default.
  • To make use of FRIENDICA_LOGFILE requires to check for the correct permission on the folder from the entrypoint.sh script. To do so I needed to add sudo to the installed packages (not really a security issue but not best practice).
  • I haven't tested with Alpine (not sure if Alpine suports sudo out of the box).
  • The correct solution would be that Friendica itself creates the file upon start or when enabled/changed in the UI. It seems as if it honors the location from then environment variable (which is good).

@ne20002
Copy link
Collaborator Author

ne20002 commented Aug 30, 2025

I believe there is no elegant way to create the logfile with the docker image.
The possible options left are:

  • just create an empty friendica.log file in /var/www/html in Dockerfile as this is the logfile default and it would by placed in a writable volume

For using Docker usually users would mount the log file and if so, the logfile needs to exist anyway.
In all other cases I believe the underlying problem should be fixed in Friendica.

@mfxa, @nupplaphil: do you agree?

@marcusxss
Copy link

marcusxss commented Sep 10, 2025

For some reason i can't make a direct comment on your new "comment", so responding here instead:

I believe there is no elegant way to create the logfile with the docker image. The possible options left are:

* just create an empty friendica.log file in /var/www/html in Dockerfile as this is the logfile default and it would by placed in a writable volume

For using Docker usually users would mount the log file and if so, the logfile needs to exist anyway. In all other cases I believe the underlying problem should be fixed in Friendica.

@mfxa, @nupplaphil: do you agree?

I think it sounds like a better idea to create it in the Dockerfile, yes. Good idea.
Better to move as much as possible to build time, and then it only needs to be done in one place.

@ne20002
Copy link
Collaborator Author

ne20002 commented Jan 30, 2026

I will change the approach to what seems to be a good practice and

  • create symlink from /var/log/friendica.log to stdout
  • set /var/log/friendica.log as default in config.php

This would allow to read the log with the Docker log handling by default. It is still possible to mount a file to /var/log/friendica.log or a folder to /var/log/.

And existing installations should not be affected (if their config is stored in the database).

@ne20002 ne20002 force-pushed the feat/logfile branch 3 times, most recently from 7be2bdc to 2be33fb Compare January 30, 2026 12:24
@ne20002 ne20002 requested a review from Copilot January 30, 2026 19:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #15001 where Friendica does not create its log file when logging is enabled. The solution changes the default log file location from /var/www/html/friendica.log to /var/log/friendica.log and creates a symbolic link to /dev/stdout, following Docker logging best practices.

Changes:

  • Updated default logfile path from /var/www/html/friendica.log to /var/log/friendica.log in all Docker configuration files
  • Added symlink creation from /var/log/friendica.log to /dev/stdout in all Dockerfiles to redirect logs to Docker's logging system
  • Applied changes consistently across all variants (apache, fpm, fpm-alpine) and versions (2024.12, 2026.01, 2026.04-dev)

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
Dockerfile-debian.template Template file: Added symlink creation for Debian-based variants
Dockerfile-alpine.template Template file: Added symlink creation for Alpine-based variants
.config/zz-docker.config.php Template config: Changed logfile path to /var/log/friendica.log
2026.04-dev/fpm/Dockerfile Development FPM variant: Added symlink to stdout
2026.04-dev/fpm/config/zz-docker.config.php Development FPM config: Updated logfile path
2026.04-dev/fpm-alpine/Dockerfile Development FPM Alpine variant: Added symlink to stdout
2026.04-dev/fpm-alpine/config/zz-docker.config.php Development FPM Alpine config: Updated logfile path
2026.04-dev/apache/Dockerfile Development Apache variant: Added symlink to stdout
2026.04-dev/apache/config/zz-docker.config.php Development Apache config: Updated logfile path
2026.01/fpm/Dockerfile Release 2026.01 FPM variant: Added symlink to stdout
2026.01/fpm/config/zz-docker.config.php Release 2026.01 FPM config: Updated logfile path
2026.01/fpm-alpine/Dockerfile Release 2026.01 FPM Alpine variant: Added symlink to stdout
2026.01/fpm-alpine/config/zz-docker.config.php Release 2026.01 FPM Alpine config: Updated logfile path
2026.01/apache/Dockerfile Release 2026.01 Apache variant: Added symlink to stdout
2026.01/apache/config/zz-docker.config.php Release 2026.01 Apache config: Updated logfile path
2024.12/fpm/Dockerfile Release 2024.12 FPM variant: Added symlink to stdout
2024.12/fpm/config/zz-docker.config.php Release 2024.12 FPM config: Updated logfile path
2024.12/fpm-alpine/Dockerfile Release 2024.12 FPM Alpine variant: Added symlink to stdout
2024.12/fpm-alpine/config/zz-docker.config.php Release 2024.12 FPM Alpine config: Updated logfile path
2024.12/apache/Dockerfile Release 2024.12 Apache variant: Added symlink to stdout
2024.12/apache/config/zz-docker.config.php Release 2024.12 Apache config: Updated logfile path

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ne20002 ne20002 marked this pull request as ready for review January 31, 2026 12:05
@ne20002 ne20002 requested a review from marcusxss January 31, 2026 16:16
@ne20002 ne20002 self-assigned this Feb 2, 2026
@ne20002 ne20002 requested review from nupplaphil and removed request for marcusxss February 2, 2026 08:49
@nupplaphil
Copy link
Collaborator

Why not setting to syslog so there won't be a logfile? There's a env for switching it

@ne20002
Copy link
Collaborator Author

ne20002 commented Feb 5, 2026

Actually it is best practice. It is not recommended to log to syslog, journal or a log file inside the container as this log would be gone when the container is stopped.
Docker picks up the stdout and stderr from inside the container. It can then be configured using Docker log drivers how to store them on the host.
With this approach it is still possible to mount a log file into the container (some people prefer this).

@nupplaphil
Copy link
Collaborator

I see, maybe some kind of doc but the rest seems fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants