Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Use env APP_NAME variable for syslog identifier #22267

Merged
merged 3 commits into from
Dec 1, 2017

Conversation

akaroot
Copy link
Contributor

@akaroot akaroot commented Dec 1, 2017

Instead of hardcoded syslog identifier "laravel" I propose to use environment variable APP_NAME.
In case when you have a few Laravel projects on the same machine that log to syslog all of them will write to log with same identifier "laravel" thats not very transparent which message belongs to which project

Instead of hardcoded syslog identifier "laravel" I propose to use environment variable APP_NAME.
In case when you have a few Laravel projects on the same machine that log to syslog all of them will write to log with same identifier "laravel" thats not very transparent which message belongs to which project
@@ -101,7 +101,7 @@ protected function configureDailyHandler(Writer $log)
*/
protected function configureSyslogHandler(Writer $log)
{
$log->useSyslog('laravel', $this->logLevel());
$log->useSyslog(env('APP_NAME', 'laravel'), $this->logLevel());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use config('app.name') instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, thanks

@taylorotwell taylorotwell merged commit aea4d49 into laravel:master Dec 1, 2017
@browner12
Copy link
Contributor

@akaroot I feel like we should add a fallback of 'laravel'.

$log->useSyslog($this->app->make('config')->get('app.name', 'laravel'), $this->logLevel());

While unlikely that this config key is missing, we don't want an empty value if it is missing.

@akaroot
Copy link
Contributor Author

akaroot commented Dec 1, 2017

@browner12 useSyslog method already has a fallback for empty name
public function useSyslog($name = 'laravel', $level = 'debug', $facility = LOG_USER)

@jmarcher
Copy link
Contributor

jmarcher commented Dec 1, 2017

@akaroot that value will be overriden if config('app.name') is null, but inside config/app.php there is already a fallback for the app name.

@GrahamCampbell GrahamCampbell changed the title Use env APP_NAME variable for syslog identifier [5.6] Use env APP_NAME variable for syslog identifier Dec 2, 2017
@barryvdh
Copy link
Contributor

barryvdh commented Sep 26, 2018

Would it make sense to change this to use a hyphen seperated string? When using spaces, it looks kinda weird in Papertrail. Not sure about other services.
Eg. 'My Cool App' would be: my-cool-app, similar to other services (systemd-logind etc)

Papertrail also uses some logic to filter or group by name, which fails when using spaces..

Edit: See #25784

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants