PHPackages                             devnav2902/utilitylog - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. devnav2902/utilitylog

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

devnav2902/utilitylog
=====================

Write a custom message in log

1.0.1(2y ago)0266MITPHPPHP ^8.1

Since May 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/devnav2902/utilitylog)[ Packagist](https://packagist.org/packages/devnav2902/utilitylog)[ RSS](/packages/devnav2902-utilitylog/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Utilitylog - Write a custom message in laravel log
==================================================

[](#utilitylog---write-a-custom-message-in-laravel-log)

This package help you write a custom log message, customize based on LineFormatter - [Monolog](https://github.com/Seldaek/monolog)

Installation
------------

[](#installation)

Install the latest version with command:

> composer require devnav2902/utilitylog

Basic Usage
-----------

[](#basic-usage)

```
UtilityLog::writeLog('error', 'Foo');
UtilityLog::writeLog('info', 'Bar');

// in try-catch block
try {
     throw new \Exception('Something happened!');
} catch (\Throwable $th) {
     UtilityLog::writeLog('error', 'Error in try-catch block', $th);
}

// contextual information
UtilityLog::writeLog('info', 'User {id} failed to login.', null, ['id' => $user->id]);
```

Documentation
-------------

[](#documentation)

### Usage Instructions

[](#usage-instructions)

This package use LineFormatter (Monolog), so you can set a custom format like this:

> "\[%channel%\]\[%level\_name%\] %datetime%\\n%message% %extra%\\n\\n"

You can modify in config file, here is default config:

```
