I'm using the Laravel Debugbar Package to display debug information. I'm noticing that the debug bar is logging errors to the log whenever an exception occurs. I would rather this doesn't happen, since I am running my own custom exception handler which collects information in the format I prefer and I have it logging to the log file as well.
So for example when I mistype a route name, I get the message saved twice to the log file:
[2015-02-11 16:21:02] local.ERROR: Method [fdfdgfd] does not exist.
[2015-02-11 16:21:04] local.ERROR: Debugbar exception: Method
UserController::fdfdgfd() does not exist [] []
How can I disable exception logging with the Debugbar?
I know this is old, but in case anyone still needs an answer. Set
'storage' => [ 'enabled' => false, ]
In laravel-debugbar/config/debugbar.php
To prevent or disable exception logging for Debugbar package.
For completely turn off log.
open edit .env file and add DEBUGBAR_ENABLED variable as false value
DEBUGBAR_ENABLED=false
Just want to disable log files in storage directory.
Publish Debugbar configuration file by following command
php artisan vendor:publish --provider=Barryvdh\Debugbar\ServiceProvider
you will get success message like.
Copied File [\vendor\barryvdh\laravel-debugbar\config\debugbar.php] To [\config\debugbar.php]
Publishing complete.
Open \config\debugbar.php file
'storage' => [
'enabled' => false, /// here change it to false
'path' => storage_path('debugbar'),
],
I have never seen this package, but it seems like it provides decent configuration.
Try to set this value to false: https://github.com/barryvdh/laravel-debugbar/blob/1.8/src/config/config.php#L90
Related
I'm trying to set up Chrome Logger to use alongside Laravel as detailed in "Easy Laravel 5", however following the instructions throws errors, and I'm new to Laravel (and not very experienced in PHP), so I'm not sure how to resolve them. We are directed to add a piece of code to the bootstrap/app.php file to use the chrome logger in the book.
The following is a screenshot of the error screen:
The following is the site without the code excerpt:
I tried requiring the chrome.php file using require_once() in the app.php file, but the error still persists. Removing the code excerpt produces the default screen.
This is the code excerpt:
if ($app->environment('local'))
{
$app->configureMonologUsing(function($monolog)
{
$monolog->pushHandler(new \Monolog\Handler\ChromePHPHandler());
});
}
I expected to be able to use the chrome logger, but instead receive the aforementioned error screen.
Add new channel in your configuration file (config/logging.php):
'chrome' => [
'driver' => 'monolog',
'handler' => \Monolog\Handler\ChromePHPHandler::class,
'formatter' => \Monolog\Formatter\ChromePHPFormatter::class
]
Sometimes you may wish to log a message to a channel other than your application's default channel. You may use the channel method on the Log facade to retrieve and log to any channel defined in your configuration file:
Log::channel('chrome')->info('Something happened!');
If you would like to create an on-demand logging stack consisting of multiple channels, you may use the stack method:
Log::stack(['single', 'chrome'])->info('Something happened!');
You can set new channel by default in your .env file
LOG_CHANNEL=chrome
or you can set
LOG_CHANNEL=stack
and change 'stack' list of channels (config/logging.php) like this:
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'chrome'],
'ignore_exceptions' => false
]
After you can use log with all your list of channels
Log::info('General information log');
From Laravel 5.6 documentation.
The configureMonologUsing Method
If you were using the configureMonologUsing method to customize the
Monolog instance for your application, you should now create a custom
Log channel. For more information on how to create custom channels,
check out the full logging documentation.
Looks like we need to be on the earlier version for this to work.
I have a Laravel application that was not developed by me. There is some weird bar at the bottom of each page, it is some type of Laravel debugger tool.
I believe it is stored in storage/debugger. Is there a safe way I can go about checking to see if this is actually it and if so can I delete this type of tool without it affecting the application? Does anybody know what this thing is if so any advice on how to remove this safely would be greatly appreciated
Best option:
Add DEBUGBAR_ENABLED=false to your .env
This has some advantage:
The debugbar is totally disabled
You can keep APP_DEBUG=true, hence still keep error details for local development
It is not tracked by git
To completely disable the debugger
In .env
APP_DEBUG=false # No error reporting at all
Disable the debugger but still wants to receive Errors (**Recommended way)
In .env
DEBUGBAR_ENABLED=false # deguger is disabled but error reporting works
FYI: Once you changed the values on .env and it didn't reflex, clear the config using php artisan config:clear or php artisan optimize:clear
Useful Links
Errors & Logging Laravel Docs 9.x
Laravel Debugbar
Remove Laravel Debugbar
- If you want to totally remove the package, then do these steps:
$ composer remove vendor/barryvdh/laravel-debugbar
$ composer update
Disable Laravel Debugbar
Option 1: Via Env File
- If you want disable the package, without it getting tracked by Git:
Navigate to your .env file
And put DEBUGBAR_ENABLED = FALSE
Option 2: Via AppServiceProvider
- From #Ohgodwhy's answer
- FYI: This will be tracked by Git. - #Salam
Navigate to app/Providers/AppServiceProvider.php
Put this code \Debugbar::disable();
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
\Debugbar::disable();
}
}
Enabling/Disabling on run time.
You can enable or disable the debugbar during run time.
Add this into your .env file:
DEBUGBAR_ENABLED = FALSE
In runtime:
\Debugbar::enable();
\Debugbar::disable();
Or remove everything
composer remove barryvdh/laravel-debugbar
You can execute composer remove barryvdh/laravel-debugbar to permanently remove it.
Note you can also just disable the debug bar if you don't want it:
Just put \Debugbar::disable(); in your AppServiceProvider.
I am using this way:
In config/debugbar.php
'inject' => false, // this remove Inject Debugbar in Response
In this way I am keeping .php error enable.
Another way is to disable completely.
'enabled' => false,
To enable just debug-bar and disable it for session and Ajax request
'enabled' => true,
....
'storage' => [
'enabled' => false, // DebugBar stores data for session/ajax requests.
or
'capture_ajax' => false,
I removed barryvdh/laravel-debugbar from my composer.json.
When I wanted to do composer install or composer update or even php artisan config:cache I got error
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Barryvdh\Debugbar\ServiceProvider' not found
If fact the solution was removing boostrap/cache/config.php, because barryvdh/laravel-debugbar was cached (php artisan config:cache could not remove it)
Good luck!
It needs to be also removed in the providers: app/config/app.php
After:
composer remove vendor/barryvdh/laravel-debugbar
composer update
remove the line:
Barryvdh\Debugbar\ServiceProvider in app/config/app.php.
Also these folders can be deleted:
app/config/packages/barryvdh/laravel-debugbar/config.php
another Debugbar-related file somewhere under app/storage/...
Also can be removed adding this to your .css file
.phpdebugbar{
display: none;
}
I'm working on Yii2 advanced application project and I have a problem with yii2 built-in Error Handler. Here is description of my problem:
I have set errorAction in my backend configuration in this way:
'errorHandler' => [
'errorAction' => 'site/error',
],
Now, the method actionError() in the SiteController catches every application exceptions, user defined exceptions and also fatal errors, except database related exception such as yii\db\IntegrityException. I don't know why, but when such an exception occurs, actionError() does not do anything! I don't want to catch exception manually with try-catch block and I want the central ErrorHandler catches all exception.
How can I fix this problem? Thank you all specially yii experts for paying attention. Please help me to solve this strange problem.
According to this GitHub issue: yiisoft/yii2/issues/10657 and to the comment made by #Yupik you must change the YII_DEBUG.
If YII_DEBUG is true, you should see proper message about yii\db\IntegrityException in debug mode.
If YII_DEBUG is false(like in a production enviroment) error is redirected to actionError() and see it in a user-friendly mode.
In a page on my site I receive this error about debug toolbar, as suggested in other answera at similar question:
The directory /runtime and all sub-dir have right chmod permissions, after some test I've tried with 777 mode but the error remains (is bad I know, but is only for test);
The index.data have not the tag wich generate the error;
After run composer update command the error wasn't solved;
No error logs was generated in runtime/logs folder;
In a first time the xdebug module was not installed, after I've installed the extension error was not solved;
[Edit 1] The /runtime dir was be cleaned after every test
The debug module configurations:
`$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
'allowedIPs' => ['127.0.0.1'],
];`
The site is made by advanced template, someone have an idea about how I can solve this problem?
The Yii2 advance template has two runtime folders, the backend runtime and the frontend runtime
You need to clear one you are debugging.
I ran command
php artisan optimize
and changed debug settings in app.php file to be
'debug' => 'true',
and added 'everyone' to have full access over 'storage' folder. I don't know what else I can do to let debugger work in my Laravel 5 project.
I'm stuck with 'Whoops, looks like something went wrong' message.
Any Ideas??
The debug => true will just show you the full error stack when you hit an error with your app. It doesn't give metrics and statistics. If you are looking for that kind of information check out the article here:
https://laravel-news.com/2015/02/laravel-debugbar/
The error you are receiving is a general error, likely server-side configuration. Without any information on your setup it will be pretty hard to determine what your issue is. Based upon your question and comments to others responses I have a couple of things for you.
You stated "I don't know what else I can do to let debugger work in my Laravel 5 project". Laravel 5 doesn't have a native debugger any more which I imagine is why your page just shows "Whoops, looks like something went wrong". Your statement would indicate that you have a debugger, so which are you trying to use, or was that statement incorrect?
You stated that you changed the debug settings the app.php file. Is there a reason why you changed this in app.php? The debug setting by default is 'debug' => env('APP_DEBUG') which is sufficient in most cases. You should have a .env file in the root of your project (created automatically if you did a composer create-project, if not you need to copy .env.example to .env on your own). The .env file will enable debug for you as there is a line that states APP_DEBUG=true.
Jesse Schutt gave great information in his response above (which I recommend upvoting), including a link to a debug bar that is compatible with L5. Yet again you are stating that you are satisfied with your error stack which implies that you actually have one. If you were satisfied with it, you would have no need to have posted here as you would already have more information on your error. If you are assuming that the filp/whoops is in l5 still and that's what you want you'll have to re-enable it. Follow the instructions at http://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5