Improve logging
This commit is contained in:
parent
300dabe6b4
commit
6361131d3f
|
|
@ -6,8 +6,7 @@ daemonize = no
|
||||||
[www]
|
[www]
|
||||||
env[DATABASE_URL] = $DATABASE_URL
|
env[DATABASE_URL] = $DATABASE_URL
|
||||||
env[DEBUG] = $DEBUG
|
env[DEBUG] = $DEBUG
|
||||||
env[DEBUG_FILE] = $DEBUG_FILE
|
env[LOG_DRIVER] = stderr
|
||||||
env[ENABLE_SYSLOG] = $ENABLE_SYSLOG
|
|
||||||
|
|
||||||
catch_workers_output = yes
|
catch_workers_output = yes
|
||||||
user = nginx
|
user = nginx
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ use Psr\Log\LogLevel;
|
||||||
use Pimple\Container;
|
use Pimple\Container;
|
||||||
use Pimple\ServiceProviderInterface;
|
use Pimple\ServiceProviderInterface;
|
||||||
use SimpleLogger\Logger;
|
use SimpleLogger\Logger;
|
||||||
|
use SimpleLogger\Stderr;
|
||||||
|
use SimpleLogger\Stdout;
|
||||||
use SimpleLogger\Syslog;
|
use SimpleLogger\Syslog;
|
||||||
use SimpleLogger\File;
|
use SimpleLogger\File;
|
||||||
|
|
||||||
|
|
@ -14,19 +16,32 @@ class LoggingProvider implements ServiceProviderInterface
|
||||||
public function register(Container $container)
|
public function register(Container $container)
|
||||||
{
|
{
|
||||||
$logger = new Logger;
|
$logger = new Logger;
|
||||||
|
$driver = null;
|
||||||
|
|
||||||
if (ENABLE_SYSLOG) {
|
switch (LOG_DRIVER) {
|
||||||
$syslog = new Syslog('kanboard');
|
case 'syslog':
|
||||||
$syslog->setLevel(LogLevel::ERROR);
|
$driver = new Syslog('kanboard');
|
||||||
$logger->setLogger($syslog);
|
break;
|
||||||
|
case 'stdout':
|
||||||
|
$driver = new Stdout();
|
||||||
|
break;
|
||||||
|
case 'stderr':
|
||||||
|
$driver = new Stderr();
|
||||||
|
break;
|
||||||
|
case 'file':
|
||||||
|
$driver = new File(LOG_FILE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) {
|
if ($driver !== null) {
|
||||||
$logger->setLogger(new File(DEBUG_FILE));
|
if (! DEBUG) {
|
||||||
|
$driver->setLevel(LogLevel::INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
$logger->setLogger($driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
$container['logger'] = $logger;
|
$container['logger'] = $logger;
|
||||||
|
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,13 @@ defined('FILES_DIR') or define('FILES_DIR', DATA_DIR.DIRECTORY_SEPARATOR.'files'
|
||||||
defined('PLUGINS_DIR') or define('PLUGINS_DIR', ROOT_DIR.DIRECTORY_SEPARATOR.'plugins');
|
defined('PLUGINS_DIR') or define('PLUGINS_DIR', ROOT_DIR.DIRECTORY_SEPARATOR.'plugins');
|
||||||
|
|
||||||
// Enable/disable debug
|
// Enable/disable debug
|
||||||
defined('DEBUG') or define('DEBUG', getenv('DEBUG'));
|
defined('DEBUG') or define('DEBUG', strtolower(getenv('DEBUG')) === 'true');
|
||||||
defined('DEBUG_FILE') or define('DEBUG_FILE', getenv('DEBUG_FILE') ?: DATA_DIR.DIRECTORY_SEPARATOR.'debug.log');
|
|
||||||
|
// Logging drivers: syslog, stdout, stderr or file
|
||||||
|
defined('LOG_DRIVER') or define('LOG_DRIVER', getenv('LOG_DRIVER'));
|
||||||
|
|
||||||
|
// Logging file
|
||||||
|
defined('LOG_FILE') or define('LOG_FILE', DATA_DIR.DIRECTORY_SEPARATOR.'debug.log');
|
||||||
|
|
||||||
// Application version
|
// Application version
|
||||||
defined('APP_VERSION') or define('APP_VERSION', build_app_version('$Format:%d$', '$Format:%H$'));
|
defined('APP_VERSION') or define('APP_VERSION', build_app_version('$Format:%d$', '$Format:%H$'));
|
||||||
|
|
@ -96,9 +101,6 @@ defined('ENABLE_HSTS') or define('ENABLE_HSTS', true);
|
||||||
// Enable or disable "X-Frame-Options: DENY" HTTP header
|
// Enable or disable "X-Frame-Options: DENY" HTTP header
|
||||||
defined('ENABLE_XFRAME') or define('ENABLE_XFRAME', true);
|
defined('ENABLE_XFRAME') or define('ENABLE_XFRAME', true);
|
||||||
|
|
||||||
// Syslog
|
|
||||||
defined('ENABLE_SYSLOG') or define('ENABLE_SYSLOG', getenv('ENABLE_SYSLOG'));
|
|
||||||
|
|
||||||
// Escape html inside markdown text
|
// Escape html inside markdown text
|
||||||
defined('MARKDOWN_ESCAPE_HTML') or define('MARKDOWN_ESCAPE_HTML', true);
|
defined('MARKDOWN_ESCAPE_HTML') or define('MARKDOWN_ESCAPE_HTML', true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
"erusev/parsedown" : "1.6.0",
|
"erusev/parsedown" : "1.6.0",
|
||||||
"fguillot/json-rpc" : "1.1.0",
|
"fguillot/json-rpc" : "1.1.0",
|
||||||
"fguillot/picodb" : "1.0.10",
|
"fguillot/picodb" : "1.0.10",
|
||||||
"fguillot/simpleLogger" : "1.0.0",
|
"fguillot/simpleLogger" : "1.0.1",
|
||||||
"fguillot/simple-validator" : "1.0.0",
|
"fguillot/simple-validator" : "1.0.0",
|
||||||
"paragonie/random_compat": "@stable",
|
"paragonie/random_compat": "@stable",
|
||||||
"pimple/pimple" : "~3.0",
|
"pimple/pimple" : "~3.0",
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "d3e42867a9978b7e3f2dbf0861e73519",
|
"hash": "82919780935641d67b876686f590fef1",
|
||||||
"content-hash": "3f031c0bd8d109e424d67a4d59cde8e3",
|
"content-hash": "9f74907d3c4ec204ff714821eecd75f9",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "christian-riesen/base32",
|
"name": "christian-riesen/base32",
|
||||||
|
|
@ -312,16 +312,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fguillot/simpleLogger",
|
"name": "fguillot/simpleLogger",
|
||||||
"version": "v1.0.0",
|
"version": "v1.0.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/fguillot/simpleLogger.git",
|
"url": "https://github.com/fguillot/simpleLogger.git",
|
||||||
"reference": "f9f46439219749a67cefe0983286d540739ba973"
|
"reference": "c6831841193bb265b7900ecc8b6a8918371a7c98"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/fguillot/simpleLogger/zipball/f9f46439219749a67cefe0983286d540739ba973",
|
"url": "https://api.github.com/repos/fguillot/simpleLogger/zipball/c6831841193bb265b7900ecc8b6a8918371a7c98",
|
||||||
"reference": "f9f46439219749a67cefe0983286d540739ba973",
|
"reference": "c6831841193bb265b7900ecc8b6a8918371a7c98",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|
@ -345,7 +345,7 @@
|
||||||
],
|
],
|
||||||
"description": "PHP library to write logs (compatible with PSR-3)",
|
"description": "PHP library to write logs (compatible with PSR-3)",
|
||||||
"homepage": "https://github.com/fguillot/simpleLogger",
|
"homepage": "https://github.com/fguillot/simpleLogger",
|
||||||
"time": "2015-08-29 14:44:37"
|
"time": "2016-05-07 18:01:57"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "gregwar/captcha",
|
"name": "gregwar/captcha",
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,11 @@
|
||||||
// Enable/Disable debug
|
// Enable/Disable debug
|
||||||
define('DEBUG', false);
|
define('DEBUG', false);
|
||||||
|
|
||||||
// Debug file path
|
// Available log drivers: syslog, stderr, stdout or file
|
||||||
define('DEBUG_FILE', __DIR__.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'debug.log');
|
define('LOG_DRIVER', '');
|
||||||
|
|
||||||
|
// Log filename if the log driver is "file"
|
||||||
|
define('LOG_FILE', __DIR__.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'debug.log');
|
||||||
|
|
||||||
// Plugins directory
|
// Plugins directory
|
||||||
define('PLUGINS_DIR', 'plugins');
|
define('PLUGINS_DIR', 'plugins');
|
||||||
|
|
@ -168,9 +171,6 @@ define('ENABLE_HSTS', true);
|
||||||
// Enable or disable "X-Frame-Options: DENY" HTTP header
|
// Enable or disable "X-Frame-Options: DENY" HTTP header
|
||||||
define('ENABLE_XFRAME', true);
|
define('ENABLE_XFRAME', true);
|
||||||
|
|
||||||
// Enable syslog logging
|
|
||||||
define('ENABLE_SYSLOG', true);
|
|
||||||
|
|
||||||
// Escape html inside markdown text
|
// Escape html inside markdown text
|
||||||
define('MARKDOWN_ESCAPE_HTML', true);
|
define('MARKDOWN_ESCAPE_HTML', true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,13 @@ Enable/Disable debug mode
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
```php
|
```php
|
||||||
define('DEBUG', false);
|
define('DEBUG', true);
|
||||||
|
define('LOG_DRIVER', 'file'); // Other drivers are: syslog, stdout, stderr or file
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The log driver must be defined if you enable the debug mode.
|
||||||
The debug mode logs all SQL queries and the time taken to generate pages.
|
The debug mode logs all SQL queries and the time taken to generate pages.
|
||||||
|
|
||||||
Debug file path
|
|
||||||
---------------
|
|
||||||
|
|
||||||
```php
|
|
||||||
define('DEBUG_FILE', __DIR__.'/data/debug.log');
|
|
||||||
```
|
|
||||||
|
|
||||||
All debug information are saved in this file.
|
|
||||||
If you prefer to send logs to `stdout` or `stderr` replace the value by `php://stdout` or `php://stderr`.
|
|
||||||
|
|
||||||
Plugins folder
|
Plugins folder
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|
@ -157,6 +149,9 @@ define('LDAP_USER_ATTRIBUTE_EMAIL', 'mail');
|
||||||
// LDAP attribute to find groups in user profile
|
// LDAP attribute to find groups in user profile
|
||||||
define('LDAP_USER_ATTRIBUTE_GROUPS', 'memberof');
|
define('LDAP_USER_ATTRIBUTE_GROUPS', 'memberof');
|
||||||
|
|
||||||
|
// LDAP attribute for user avatar image: thumbnailPhoto or jpegPhoto
|
||||||
|
define('LDAP_USER_ATTRIBUTE_PHOTO', '');
|
||||||
|
|
||||||
// Allow automatic LDAP user creation
|
// Allow automatic LDAP user creation
|
||||||
define('LDAP_USER_CREATION', true);
|
define('LDAP_USER_CREATION', true);
|
||||||
|
|
||||||
|
|
@ -227,13 +222,18 @@ define('ENABLE_XFRAME', true);
|
||||||
Logging
|
Logging
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
By default, Kanboard do not log anything.
|
||||||
|
If you want to enable the logging, you have to set a log driver.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Enable syslog logging
|
// Available log drivers: syslog, stderr, stdout or file
|
||||||
// Set to false to disable syslog
|
define('LOG_DRIVER', '');
|
||||||
define('ENABLE_SYSLOG', true);
|
|
||||||
|
// Log filename if the log driver is "file"
|
||||||
|
define('LOG_FILE', __DIR__.DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'debug.log');
|
||||||
```
|
```
|
||||||
|
|
||||||
Bruteforce protection
|
Brute-force protection
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,5 @@ Environment variables maybe useful when Kanboard is deployed as container (Docke
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
|---------------|---------------------------------------------------------------------------------------------------------------------------------|
|
|---------------|---------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| DATABASE_URL | `[database type]://[username]:[password]@[host]:[port]/[database name]`, example: `postgres://foo:foo@myserver:5432/kanboard` |
|
| DATABASE_URL | `[database type]://[username]:[password]@[host]:[port]/[database name]`, example: `postgres://foo:foo@myserver:5432/kanboard` |
|
||||||
| DEBUG | Enable/Disable debug mode |
|
| DEBUG | Enable/Disable debug mode: "true" or "false" |
|
||||||
| DEBUG_FILE | Debug file location, `DEBUG_FILE=php://stderr` |
|
| LOG_DRIVER | Logging driver: stdout, stderr, file or syslog |
|
||||||
| ENABLE_SYSLOG | Enable/Disable logging to Syslog: `ENABLE_SYSLOG=1` |
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue