Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ENV variable for nextcloud logging behavior #1754

Closed
MarkusGnigler opened this issue May 18, 2022 · 6 comments
Closed

Support ENV variable for nextcloud logging behavior #1754

MarkusGnigler opened this issue May 18, 2022 · 6 comments
Labels
enhancement feature: auto config (environment variables) Auto configuring via environment variables

Comments

@MarkusGnigler
Copy link

MarkusGnigler commented May 18, 2022

In order to go with best practice for docker. Would it be usefull to implement a logging behavior via env variables?
That way it can be configured to log to SdtOut on startup.

I think it's usefull for:
- orchestrator like swarm/kubernetes.
- centralized logging
- fail2ban with docker json logging driver

For example in the alpine image we could implement another config.php somthing like log.config.php

LOGFILE=/dev/stdout
LOGTIMEZONE=Europe/Vienna
<?php

$CONFIG = array(
    'loglevel' => getenv('LOGLEVEL') ?: 2,
    'logtimezone' => getenv('LOGTIMEZONE') ?: 'Europe/Vienna',
    'syslog_tag' => getenv('LOGTAG') ?: 'Nextcloud',
);

if (getenv('LOGFILE')) {
    $CONFIG['logfile'] = getenv('LOGFILE');
} else {
    $CONFIG['logfile'] = getenv('NEXTCLOUD_DATA_DIR') ?: '/var/www/nextcloud' + '/nextcloud.log';
}

I can create a pr, but have requested before so I don't waste time on it.

Regards
Markus

@MarkusGnigler

This comment was marked as off-topic.

@attzonko
Copy link

attzonko commented Jun 6, 2022

Since it's a warning in the admin panel, would it also be a good idea to implement an env variable for the default_phone_region setting?

<?php

$CONFIG = array(
    'default_phone_region' => getenv('DEFAULT_PHONE_REGION') ?: 'EN',
);

I came here looking for such an ENV setting for the default phone region. I don't want to have to change config.php at all from the default the image comes with.

@chrisr4g
Copy link

chrisr4g commented Jun 6, 2022

Since it's a warning in the admin panel, would it also be a good idea to implement an env variable for the default_phone_region setting?

<?php

$CONFIG = array(
    'default_phone_region' => getenv('DEFAULT_PHONE_REGION') ?: 'EN',
);

I came here looking for such an ENV setting for the default phone region. I don't want to have to change config.php at all from the default the image comes with.

You can achieve any actions needed inside the container using a bash script.
Inside the bash you just have to run (if you use docker-compose)
docker-compose exec -u www-data php -f /var/www/html/occ config:system:set default_phone_region --value 'uk'
Just to be clear about it (because I struggled with it too): php occ config:system:set array (optional)key --value 'value'
!Important: You have to wait untill nextcloud is up and running to execute the command.

Also you can set the logging inside the config too, to a specific file with the same method.
Ex.:
php occ config:system:set log_type --value "file"
php occ config:system:set logfile --value "DEBUG_LOGS.log"
php occ config:system:set logLevel --value 0
php occ config:system:set logdateformat --value "F d, Y H:i:s"
However I agree it would benefit everyone to be able to set the logging from env file.

MarkusGnigler added a commit to MarkusGnigler/nextcloud-docker that referenced this issue Jun 26, 2022
MarkusGnigler added a commit to MarkusGnigler/nextcloud-docker that referenced this issue Jun 26, 2022
MarkusGnigler added a commit to MarkusGnigler/nextcloud-docker that referenced this issue Jun 26, 2022
MarkusGnigler added a commit to MarkusGnigler/nextcloud-docker that referenced this issue Jun 26, 2022
@J0WI
Copy link
Contributor

J0WI commented Aug 17, 2022

You can already use environment variables like NC_loglevel.

@Graxo

This comment was marked as off-topic.

@joshtrichards joshtrichards added enhancement feature: auto config (environment variables) Auto configuring via environment variables labels Oct 23, 2023
@joshtrichards
Copy link
Member

Closing since this is already supported in at least two ways:

@joshtrichards joshtrichards closed this as not planned Won't fix, can't repro, duplicate, stale Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature: auto config (environment variables) Auto configuring via environment variables
Projects
None yet
Development

No branches or pull requests

6 participants