Comments (4)
Log::channel('gelf')->withContext([...
from laravel-gelf-logger.
Hi, please share your configuration and code that shows something that is not working
from laravel-gelf-logger.
Middleware:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
class AssignRequestId
{
/**
* Обработчик входящего запроса
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$requestId = (string) Str::uuid();
Log::withContext([
'request-id' => $requestId
]);
$request->headers->set('Request-Id', $requestId);
return $next($request)->header('Request-Id', $requestId);
}
}
Used code:
<?php
namespace App\Http\Controllers;
use App\Http\ApiResponseInjectController;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Log;
class TokenController extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, ApiResponseInjectController;
/**
* Создание JWT
*
* @return \Illuminate\Http\JsonResponse
*/
public function generate(Request $request)
{
$payload = [
'iss' => 'localhost',
'aud' => 'localhost',
'iat' => time(),
'nbf' => time(),
'exp' => time() + 64000,
'user_id' => rand(100000, 999999),
'user_name' => 'test',
'rights' => []
];
$jwt = JWT::encode($payload, config('app.jwt_private'), 'RS256');
Log::channel('gelf')->debug('Выпущен токен JWT', ['jwt' => $jwt]);
return $this->apiResponse->getSuccess(['token' => $jwt]);
}
}
from laravel-gelf-logger.
Thanks! It really works, the IDE just highlights that there is no method and did not try.
from laravel-gelf-logger.
Related Issues (20)
- "Message is invalid" exception thrown by gelf-php when logging an empty string. HOT 3
- Log messages over HTTP to graylog HOT 5
- problem to send log to graylog HOT 4
- which version is suitalbe fo laravel 6.x ? HOT 2
- Is this package is available for Laravel 8 ? HOT 3
- PR: graylog2/gelf-php is depricated
- Multiple JSONs in one message HOT 4
- Unable to send logs to Graylog HOT 3
- RuntimeException when Graylog SSL expired HOT 5
- Breaking due to "id" field HOT 5
- Does not send data after 60 seconds of waiting HOT 4
- Laravel 10 & graylog2/gelf-php 2 compatility
- Add extra data to the gelf messages HOT 1
- Can't Receive messages on Graylog HOT 1
- udp and openvpn HOT 2
- Stuck for 8s if the remote service is unavailable HOT 5
- README.md update HOT 1
- Laravel Lumen 5.7 Error HOT 1
- Support for Laravel 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-gelf-logger.