diff --git a/config/install/jsonlog.settings.yml b/config/install/jsonlog.settings.yml
index 2709585..4d2751f 100644
--- a/config/install/jsonlog.settings.yml
+++ b/config/install/jsonlog.settings.yml
@@ -2,6 +2,6 @@ jsonlog_severity_threshold: 4
 jsonlog_truncate: 64
 jsonlog_siteid: ''
 jsonlog_canonical: ''
-jsonlog_file_time: ''
+jsonlog_file_time: 'Ymd'
 jsonlog_dir: ''
 jsonlog_tags: ''
\ No newline at end of file
diff --git a/jsonlog.inc b/jsonlog.inc
index 3193bfc..f66b49f 100644
--- a/jsonlog.inc
+++ b/jsonlog.inc
@@ -4,6 +4,7 @@
  * JSONlog module helper functions.
  */
 
+use Drupal\Core\Database\Database;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Logger\RfcLogLevel;
 use Drupal\jsonlog\Logger\JsonLogData;
@@ -319,12 +320,12 @@ function jsonlog_default_site_id() {
     return $site_id;
   }
 
+  $db_info = Database::getConnectionInfo();
   // Server's hostname + database name + database prefix (if any).
-  $db =& $GLOBALS['databases']['default']['default'];
   $site_id = strtolower(preg_replace('/[^\w\d\.\-_]/', '-', gethostname()))
-    . '__' . $db['database']
-    . (!$db['prefix'] ? '' : ('__' . $db['prefix']));
-  unset($db); // Clear ref.
+    . '__' . $db_info['default']['database']
+    . ($db_info['default']['prefix'] && !empty($db_info['default']['prefix']['default']) ? ('__' . $db_info['default']['prefix']['default']) : '');
+  unset($db_info); // Clear ref.
 
   return $site_id;
 }
diff --git a/jsonlog.services.yml b/jsonlog.services.yml
index c03e475..da4bf7e 100644
--- a/jsonlog.services.yml
+++ b/jsonlog.services.yml
@@ -1,6 +1,6 @@
 services:
   logger.jsonlog:
     class: Drupal\jsonlog\Logger\JsonLog
-    arguments: ['@config.factory', '@logger.log_message_parser']
+    arguments: ['@config.factory', '@logger.log_message_parser', '@module_handler']
     tags:
       - { name: logger }
diff --git a/src/Logger/JsonLog.php b/src/Logger/JsonLog.php
index 8874444..da64a9c 100644
--- a/src/Logger/JsonLog.php
+++ b/src/Logger/JsonLog.php
@@ -6,6 +6,7 @@ use Drupal;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Logger\LogMessageParserInterface;
 use Drupal\Core\Logger\RfcLoggerTrait;
+use Drupal\Core\Extension\ModuleHandlerInterface;
 use Psr\Log\LoggerInterface;
 
 /**
@@ -30,6 +31,11 @@ class JsonLog implements LoggerInterface {
   private $parser;
 
   /**
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface
+   */
+  private $moduleHandler;
+
+  /**
    * @var string
    */
   private $threshold;
@@ -70,16 +76,16 @@ class JsonLog implements LoggerInterface {
   private $tags_site;
 
   /**
-   * Constructs a JsonLog object.
+   * JsonLog constructor.
    *
    * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
-   *   The configuration factory object.
    * @param \Drupal\Core\Logger\LogMessageParserInterface $parser
-   *   The parser to use when extracting message variables.
+   * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
    */
-  public function __construct(ConfigFactoryInterface $config_factory, LogMessageParserInterface $parser) {
+  public function __construct(ConfigFactoryInterface $config_factory, LogMessageParserInterface $parser, ModuleHandlerInterface $moduleHandler) {
     $this->config = $config_factory->getEditable('jsonlog.settings');
     $this->parser = $parser;
+    $this->moduleHandler = $moduleHandler;
     $this->loadDefaultSettings();
   }
 
@@ -142,7 +148,7 @@ class JsonLog implements LoggerInterface {
     // Site ID
     if (!($this->site_id = getenv('drupal_jsonlog_siteid'))) {
       if (!($this->site_id = $this->config->get('jsonlog_siteid'))) {
-        module_load_include('inc', 'jsonlog');
+        $this->moduleHandler->loadInclude('jsonlog', 'inc');
         $this->config->set('jsonlog_siteid', $this->site_id = jsonlog_default_site_id());
       }
     }
@@ -155,7 +161,7 @@ class JsonLog implements LoggerInterface {
     // Dir
     if (!($this->dir = getenv('drupal_jsonlog_dir'))) {
       if (!($this->dir = $this->config->get('jsonlog_dir'))) {
-        module_load_include('inc', 'jsonlog');
+        $this->moduleHandler->loadInclude('jsonlog', 'inc');
         if (($this->dir = jsonlog_default_dir())) {
           $this->config->set('jsonlog_dir', $this->dir);
         }
