PHPackages                             kejaksaan-dev/portal-logger - 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. kejaksaan-dev/portal-logger

ActiveLibrary

kejaksaan-dev/portal-logger
===========================

Package to push log event to central logging server

1.0.6(2y ago)0335↓100%MITPHPPHP ^7.2|^8.0

Since Apr 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ridhoidong/portal-logger)[ Packagist](https://packagist.org/packages/kejaksaan-dev/portal-logger)[ RSS](/packages/kejaksaan-dev-portal-logger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (8)Used By (0)

Portal Logger
=============

[](#portal-logger)

This package adds a middleware which can log incoming requests to the log server. Besides that it can also record application error logs.

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

[](#installation)

You can install the package via composer:

```
composer require kejaksaan-dev/portal-logger
```

Usage
-----

[](#usage)

1. Setup required ENV for portal logger

    ```
    // in `.env`

    PORTAL_LOGGER_URL={URL_LOGGING_SERVER}
    PORTAL_LOGGER_APP_ID={APPID_LOGGING_SERVER}
    PORTAL_LOGGER_APP_KEY={APPKEY_LOGGING_SERVER}
    PORTAL_LOGGER_REQUEST_TIMEOUT=10
    PORTAL_LARAVEL_VERSION=10 //if laravel 9 then value is 9
    ```
2. Add providers in config app

    ```
    // in `config/app.php`

    // ...

    'providers' => [
    	//...
    	KejaksaanDev\PortalLogger\PortalLoggerServiceProvider::class,
    ]
    ```
3. Publish the config file with:

    ```
    php artisan vendor:publish --provider="KejaksaanDev\PortalLogger\PortalLoggerServiceProvider" --tag="portal-logger-config"
    ```

    This is the contents of the published config file:

    ```
    return [

    	'logger' => [
    		'url' => env('PORTAL_LOGGER_URL',
    		'https://api.kejaksaanri.id/portal-logger'),
    		'path' => env('PORTAL_LOGGER_PATH', '/api/v1/logs/create'),
    		'app_id' => env('PORTAL_LOGGER_APP_ID', 'DEFAULT'),
    		'default_status_code' => env('PORTAL_LOGGER_STATUS_CODE', '200'),
    		'is_ajax_log' => env('PORTAL_LOGGER_IS_AJAX_LOG', false),
    		'user_guard' => env('PORTAL_LOGGER_USER_GUARD', 'web'),
    		'user_id' => env('PORTAL_LOGGER_USER_ID_VAR', 'id'),
    		'user_satker_var' => env('PORTAL_LOGGER_USER_SATKER_VAR', 'satker_id'),
    		'user_nip_var' => env('PORTAL_LOGGER_USER_NIP_VAR', 'nip'),
    		'user_username_var' => env('PORTAL_LOGGER_USER_USERNAME_VAR', 'username'),
    		'user_name_var' => env('PORTAL_LOGGER_USER_NAME_VAR', 'name'),
    		'request_timeout' => env('PORTAL_LOGGER_REQUEST_TIMEOUT', 30),
    		'request_async' => env('PORTAL_LOGGER_REQUEST_ASYNC', true),
    		'cache_user' => env('PORTAL_LOGGER_CACHE_USER', 86400),
    		'is_enable' => env('PORTAL_LOGGER_IS_ENABLE', true)
    	],
    	'http_logger' => [
    		'channel' => env('PORTAL_HTTP_LOGGER_CHANNEL', 'portal-logger'),
    		'level' => env('PORTAL_HTTP_LOGGER_LEVEL', 'info'),
    		'log_profile' => \KejaksaanDev\PortalLogger\Logs\PortalLogProfile::class,
    		'log_writer' => \KejaksaanDev\PortalLogger\Logs\PortalLogWriter::class,
    	]
    ];
    ```
4. You need add middleware in middleware groups in Kernel

    ```
    // in `app/Http/Kernel.php`

    protected $middlewareGroups = [
        'web' => [
    		    // ...
    		    \KejaksaanDev\PortalLogger\Http\Middleware\PortalLogger::class
    	]
    ];
    ```
5. Add new channel in logging config

    ```
    	// in `config/logging.php`
    	return [
    		'channels' => [

    			// ...

    			'portal-logger' => [
    				'driver' => 'monolog',
    				'level' => 'debug',
    				'handler' => env('PORTAL_LARAVEL_VERSION', 10) >= 10
    						? KejaksaanDev\PortalLogger\PortalLoggerHandler::class
    						: KejaksaanDev\PortalLogger\PortalLoggerL10BellowHandler::class
    			],
    		]
    	]
    	```
    ```
6. Add report method in Exception Handler

    ```
    	// in `app\Exceptions\Handler.php`

    	use Illuminate\Support\Facades\Log;
    	use KejaksaanDev\PortalLogger\Http\Traits\WriterLogger;
    	use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
    	use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
    	use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
    	use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
    	use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;

    	//...

    	public  function  report(Throwable  $e)
    	{
    		try {
    			$statusCode = 500;
    			$className = get_class($e);

    			if ($e instanceof BadRequestHttpException) {
    				$statusCode = 400;
    			} else  if ($e instanceof MethodNotAllowedHttpException) {
    				$statusCode = 405;
    			} else  if ($e instanceof NotFoundHttpException) {
    				$statusCode = 404;
    			} else  if ($e instanceof UnauthorizedHttpException) {
    				$statusCode = 401;
    			}

    			WriterLogger::writeLog(request(), (string) $statusCode, 'error', null, $className, $e->getMessage());
    		}
    		catch (\Exception  $ex) {
    			Log::error("Failed log exception handler cause : {$ex->getMessage()}");
    		}
    	}
    	```
    ```

Credits
-------

[](#credits)

- [Spatie](https://github.com/spatie)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

7

Last Release

1080d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a840d651f0d5caf89c3e03274f835b07cc1115481006a4e3375da5d0c50a7000?d=identicon)[kejaksaan-dev](/maintainers/kejaksaan-dev)

### Embed Badge

![Health badge](/badges/kejaksaan-dev-portal-logger/health.svg)

```
[![Health](https://phpackages.com/badges/kejaksaan-dev-portal-logger/health.svg)](https://phpackages.com/packages/kejaksaan-dev-portal-logger)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
