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

Specifying channel information dynamically #224

Closed
abishekrsrikaanth opened this issue Aug 23, 2013 · 1 comment
Closed

Specifying channel information dynamically #224

abishekrsrikaanth opened this issue Aug 23, 2013 · 1 comment

Comments

@abishekrsrikaanth
Copy link

Currently the monolog makes use of the channel specified when initializing the Logger Class. Is there a way to dynamically specify the channel information.

There isn't a method setName on the Logger class and $name is a protected property so cannot actually change the channel name dynamically.

My application initializes the Logger class globally and makes use of that instance to Log throughout the application, so it is actually difficult to change the channel name.

I was thinking of something like this

$loggerObj->setName('CHANNEL_NAME');
$loggerObj->addInfo('LOG INFORMATION GOES HERE');

or

$loggerObj->addInfo('LOG INFO GOES HERE',$context,$channelName);

Could someone advice if there is a way to do this?

@Seldaek
Copy link
Owner

Seldaek commented Aug 23, 2013

That would cause bad side-effects and messy code since you would have to change the channel back to the previous value every time. The point is you can create multiple Loggers for each logical channel you have, and then add all the same handlers to each of them.

@Seldaek Seldaek closed this as completed Aug 23, 2013
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

No branches or pull requests

2 participants