Skip to content

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

Merged
taylorotwell merged 3 commits into
laravel:masterfrom
akaroot:patch-2
Dec 1, 2017
Merged

[5.6] Use env APP_NAME variable for syslog identifier#22267
taylorotwell merged 3 commits into
laravel:masterfrom
akaroot:patch-2

Conversation

@akaroot

@akaroot akaroot commented Dec 1, 2017

Copy link
Copy Markdown
Contributor

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
protected function configureSyslogHandler(Writer $log)
{
$log->useSyslog('laravel', $this->logLevel());
$log->useSyslog(env('APP_NAME', 'laravel'), $this->logLevel());

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

akaroot commented Dec 1, 2017

Copy link
Copy Markdown
Contributor Author

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

@jmarcher

jmarcher commented Dec 1, 2017

Copy link
Copy Markdown
Contributor

@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

barryvdh commented Sep 26, 2018

Copy link
Copy Markdown
Contributor

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