AthenaeumAthenaeum
Packages
  • next
  • current
  • v9.x
  • v8.x
  • v7.x
  • v6.x
  • v5.x
  • v4.x
  • v3.x
  • v2.x
  • v1.x
Changelog
GitHub
Packages
  • next
  • current
  • v9.x
  • v8.x
  • v7.x
  • v6.x
  • v5.x
  • v4.x
  • v3.x
  • v2.x
  • v1.x
Changelog
GitHub
  • Version 4.x

    • Release Notes
    • Upgrade Guide
    • New to this...
    • Origin
  • Circuits

    • Circuits
    • How to install
    • Setup
    • Usage
    • Events
  • Config

    • Configuration Loader
    • How to install
    • Setup
    • Load Configuration Files
    • Custom File Parsers
  • Console

    • Command and Schedule Registration
    • How to install
    • Setup
    • Commands
    • Schedules
  • Container

    • IoC Service Container
    • How to install
    • registerAsApplication()
    • destroy()
  • Core

    • Athenaeum Core Application
    • Prerequisite
    • How to install
    • Integration
    • Usage

      • Configuration
      • Service Providers
      • Service Container
      • Events
      • Caching
      • Logging
      • Console
      • Task Scheduling
      • Exception Handling
      • Extending Core Application
      • Testing
  • Dto

    • Data Transfer Object (DTO)
    • How to install
    • Create Interface
    • Implement DTO
    • How to use
    • Populate
    • Export
    • Json
    • Serialization
    • Nested DTOs
    • Array DTO
  • Events

    • Register Listeners and Subscribers
    • How to install
    • Setup
    • Listeners
    • Subscribers
  • Http

    • Clients

      • Http Clients
      • How to install
      • Setup
      • Basic Usage
      • Available Methods

        • Fluent Api
        • Protocol Version
        • Base Uri
        • Http Method and Uri
        • Headers
        • Accept & Content-Type
        • Authentication
        • Http Query
        • Payload Format
        • Payload
        • Attachments
        • Cookies
        • Response Expectations
        • Conditions
        • Criteria
        • Redirects
        • Timeout
        • Driver Options
        • Driver
      • Http Query Builder

        • Introduction
        • Select
        • Where
        • Dates
        • Include
        • Pagination
        • Sorting
        • Raw Expressions
        • Custom Grammar
    • Cookies

      • Http Cookies
      • How to install
      • Usage
  • Properties

    • Properties Overload
    • How to install
    • Usage
    • Naming Convention
    • Properties Visibility
  • Service

    • Service Registrar
    • How to install
    • How to use
  • Support

    • Introduction
    • How to install
    • Laravel Aware-of Helpers

      • How to use
      • Enforce Via Interface
      • Custom Default
      • Pros and Cons
      • Available Helpers
    • Aware-of Properties

      • Generator
      • Available Aware-of Helpers
    • Live Templates
  • Testing

    • Introduction
    • How to install
    • Test Cases
    • Testing Aware-of Helpers
  • Utils

    • Introduction
    • How to install
    • Array
    • Json
    • Math
    • Method Helper
    • Populatable
    • Version
You are viewing documentation for an outdated version. It is no longer supported!

Logging

Some of Laravel's services depend on the Logging package[1]. Should you stumble across such a dependency, then you might be required to install it, in order to get the service to work as intended.

[1]: The illuminate/log package uses MonoLog.

How to install

composer require illuminate/log

Logger Configuration

Copy the logging.php configuration file from Laravel's Repository, and place it within your /configs directory. You can read more about the configuration in Laravel's documentation.

Register LogServiceProvider

Add the class path to LogServiceProvider in your providers array, in your /configs/app.php configuration file.

<?php
return [
    // ... previous not shown ...

    'providers' => [
        \Illuminate\Log\LogServiceProvider::class,
    ],

    // ... remaining not shown ...
];

At this point, you should have logging available in your application.

Folder Permissions

If you chose a log-profile that stores log entries in files, then please ensure that storage directory has the correct permissions. For instance, if you chose to store log-files in the /storage/logs directory, you could change the permissions to the following:

chown -R www-data:www-data /storage/logs

The above example applies to Linux environments. Please seek appropriate guidance regarding read/write permissions, if you work on a difference type of server environment.

Usage

Via $app

If your $app is available, then use the make() method to obtain the logger instance.

<?php
// Obtain logger instance
$logger = $app->make('log');

$logger->info('Logger works great');

Via Log Facade

You can also use Laravel's Log Facade.

<?php
use Illuminate\Support\Facades\Log;

Log::warning('User is missing contact information', [ 'user' => $user ]);

Via Aware-of Helper

Alternatively, you can make use of the Log Aware-of Helper.

<?php
use Aedart\Support\Helpers\Logging\LogTrait;

class DeviceRegistrationController
{
    use LogTrait;

    public function index()
    {
        // ... previous not shown ...

        $logger = $this->getLog();

        $logger->debug('Device requesting registration', [ 'device' => '...' ]);

        // ... Remaining not shown ...
    }
}
Edit page
Last Updated: 08/09/2020, 18:52
Contributors: Alin Eugen Deac
Prev
Caching
Next
Console