symfony
symfony forum
Home » support » General discussion » How to use Logger ?
How to use Logger ? [message #30433] Thu, 28 June 2007 10:13 Go to next message
wace  is currently offline wace
Messages: 19
Registered: May 2007
Location: Grenoble
Junior Member
Hi all,

I'm new on Symfony, and i'm not able to find how use a Logger object to trace code execution in my Action class or Template file,

Do you help by code examples and requirement to config a logger object ?

thx,

Re: How to use Logger ? [message #30435 is a reply to message #30433 ] Thu, 28 June 2007 10:19 Go to previous messageGo to next message
al_n  is currently offline al_n
Messages: 321
Registered: May 2006
Location: The Netherlands
Faithful Member
in an action you can do:
$this->logMessage($message);

or you can do this everywhere:
sfContext::getInstance()->getLogger()->info($message);
Re: How to use Logger ? [message #30436 is a reply to message #30435 ] Thu, 28 June 2007 10:24 Go to previous messageGo to next message
wace  is currently offline wace
Messages: 19
Registered: May 2007
Location: Grenoble
Junior Member
Hey Thx for your answer it works fine,

And how i can use it in template ?

Re: How to use Logger ? [message #30438 is a reply to message #30433 ] Thu, 28 June 2007 10:46 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 8440
Registered: January 2006
Location: West Midlands, UK
Faithful Member
You shouldn't use it in a template - that would break the MVC model.


Remember Gaza | Connect 2 Theatre
Re: How to use Logger ? [message #30440 is a reply to message #30436 ] Thu, 28 June 2007 10:58 Go to previous messageGo to next message
torsten  is currently offline torsten
Messages: 162
Registered: November 2006
Location: Frankfurt/ Germany
Senior Member
Anyway, you could use the Debug Helper in Templates see:

http://www.symfony-project.com/book/trunk/16-Application-Man agement-Tools#Debugging

<?php use_helper('Debug') ?>
...
<?php if ($problem): ?>
  <?php log_message('{sfAction} been there', 'err') ?>
  ...
<?php endif ?>
Re: How to use Logger ? [message #30450 is a reply to message #30438 ] Thu, 28 June 2007 15:07 Go to previous messageGo to next message
al_n  is currently offline al_n
Messages: 321
Registered: May 2006
Location: The Netherlands
Faithful Member
halfer wrote on Thu, 28 June 2007 10:46

You shouldn't use it in a template - that would break the MVC model.


What has logging to do with MVC? Nothing!
Re: How to use Logger ? [message #30453 is a reply to message #30433 ] Thu, 28 June 2007 15:41 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 8440
Registered: January 2006
Location: West Midlands, UK
Faithful Member
al_n, I can't quite tell if you're trying to be rude, but it sounds like it. Surely you can manage a more diplomatic tone than that?

MVC, as I am sure you know, is about the separation of concerns between logic and presentation. I regard application logging as logic that firmly does not belong in the presentation layer, so I would still maintain that my comment was correct. Debugging logging, on the other hand, can go anywhere, which is perhaps what you had in mind.

[Edit: unsubscribing from thread]

[Updated on: Thu, 28 June 2007 15:42]


Remember Gaza | Connect 2 Theatre
Re: How to use Logger ? [message #30477 is a reply to message #30453 ] Fri, 29 June 2007 00:07 Go to previous message
al_n  is currently offline al_n
Messages: 321
Registered: May 2006
Location: The Netherlands
Faithful Member
halfer wrote on Thu, 28 June 2007 15:41

al_n, I can't quite tell if you're trying to be rude, but it sounds like it. Surely you can manage a more diplomatic tone than that?

MVC, as I am sure you know, is about the separation of concerns between logic and presentation. I regard application logging as logic that firmly does not belong in the presentation layer, so I would still maintain that my comment was correct. Debugging logging, on the other hand, can go anywhere, which is perhaps what you had in mind.

[Edit: unsubscribing from thread]


My dear halfer,
I didn't intend to be rude but when people are asking about logging in order to trace code execution then I assume they are trying to debug something. You can surely understand that debugging is also something you are doing in your presentation layer. More then that, logging is not logic, its just .... logging and it is not breaking the definition of the MVC design pattern if it happens in the view.
Previous Topic:How to create a reusable SELECT with dynamic "Other" field
Next Topic:How to do it with one or two queries?
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software