docker
docker copied to clipboard
Support ENV variable for nextcloud logging behavior
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
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',
);
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.
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.
You can already use environment variables like NC_loglevel.
Is there a way to reload the .env file? There is a mistake in the email settings and chanching it in the config.php doesnt work.