You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by "Gary Richardson (JIRA)" <ji...@apache.org> on 2008/07/17 18:33:31 UTC

[jira] Created: (LOG4PHP-16) Patch for LoggerAppenderSyslog to use Layouts

Patch for LoggerAppenderSyslog to use Layouts
---------------------------------------------

                 Key: LOG4PHP-16
                 URL: https://issues.apache.org/jira/browse/LOG4PHP-16
             Project: Log4php
          Issue Type: Improvement
            Reporter: Gary Richardson
            Priority: Minor


I noticed that LoggerAppenderSyslog seems to ignore layouts. I'm not sure if this is by design.

The following patch causes LoggerAppenderSyslog to use layouts:

Index: src/main/php/appenders/LoggerAppenderSyslog.php
===================================================================
--- src/main/php/appenders/LoggerAppenderSyslog.php     (revision 677439)
+++ src/main/php/appenders/LoggerAppenderSyslog.php     (working copy)
@@ -86,6 +86,11 @@
      */
     private $_overridePriority;
 
+       public function __construct($name) {
+               parent::__construct($name);
+               $this->requiresLayout = true;
+       }
+    
         /**
      * Set the ident of the syslog message.
      *
@@ -156,7 +161,12 @@
         openlog($this->_ident, $this->_option, $this->_facility);
         
         $level   = $event->getLevel();
-        $message = $event->getRenderedMessage();
+        if(null == $this->layout) {
+               $message = $event->getRenderedMessage();
+        }
+        else {
+               $message = $this->layout->format($event);
+        }
         
         // If the priority of a syslog message can be overridden by a value defined in the properties-file,
         // use that value, else use the one that is defined in the code.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (LOG4PHP-16) Patch for LoggerAppenderSyslog to use Layouts

Posted by "Knut Urdalen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4PHP-16?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Urdalen resolved LOG4PHP-16.
---------------------------------

    Resolution: Fixed
      Assignee: Knut Urdalen

Marshall has a good point about size limits for syslog, anyway it's totally reasonable to use layouts in the syslog-appender as well. In example if you want to use MDC properties.


> Patch for LoggerAppenderSyslog to use Layouts
> ---------------------------------------------
>
>                 Key: LOG4PHP-16
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-16
>             Project: Log4php
>          Issue Type: Improvement
>          Components: Code
>            Reporter: Gary Richardson
>            Assignee: Knut Urdalen
>            Priority: Minor
>             Fix For: 2.0
>
>         Attachments: LoggerAppenderSyslog.patch
>
>
> I noticed that LoggerAppenderSyslog seems to ignore layouts. I'm not sure if this is by design.
> The following patch causes LoggerAppenderSyslog to use layouts:
> Index: src/main/php/appenders/LoggerAppenderSyslog.php
> ===================================================================
> --- src/main/php/appenders/LoggerAppenderSyslog.php     (revision 677439)
> +++ src/main/php/appenders/LoggerAppenderSyslog.php     (working copy)
> @@ -86,6 +86,11 @@
>       */
>      private $_overridePriority;
>  
> +       public function __construct($name) {
> +               parent::__construct($name);
> +               $this->requiresLayout = true;
> +       }
> +    
>          /**
>       * Set the ident of the syslog message.
>       *
> @@ -156,7 +161,12 @@
>          openlog($this->_ident, $this->_option, $this->_facility);
>          
>          $level   = $event->getLevel();
> -        $message = $event->getRenderedMessage();
> +        if(null == $this->layout) {
> +               $message = $event->getRenderedMessage();
> +        }
> +        else {
> +               $message = $this->layout->format($event);
> +        }
>          
>          // If the priority of a syslog message can be overridden by a value defined in the properties-file,
>          // use that value, else use the one that is defined in the code.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LOG4PHP-16) Patch for LoggerAppenderSyslog to use Layouts

Posted by "Marshall Pierce (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-16?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12614454#action_12614454 ] 

Marshall Pierce commented on LOG4PHP-16:
----------------------------------------

I think that formatting of events is typically left to the syslog daemon you choose to run. That could be a reason why that appender does not use formatting. Also, syslog is commonly sent over UDP, which imposes a quite restrictive size limit. See http://www.mail-archive.com/syslog-sec@employees.org/msg01623.html for more on that size limit.

I'm not necessarily saying having a layout is a bad thing (you could always choose a very simple layout), but keep in mind that messages may end up truncated if you have a fancy layout that has lots of extra non-message information.

> Patch for LoggerAppenderSyslog to use Layouts
> ---------------------------------------------
>
>                 Key: LOG4PHP-16
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-16
>             Project: Log4php
>          Issue Type: Improvement
>            Reporter: Gary Richardson
>            Priority: Minor
>         Attachments: LoggerAppenderSyslog.patch
>
>
> I noticed that LoggerAppenderSyslog seems to ignore layouts. I'm not sure if this is by design.
> The following patch causes LoggerAppenderSyslog to use layouts:
> Index: src/main/php/appenders/LoggerAppenderSyslog.php
> ===================================================================
> --- src/main/php/appenders/LoggerAppenderSyslog.php     (revision 677439)
> +++ src/main/php/appenders/LoggerAppenderSyslog.php     (working copy)
> @@ -86,6 +86,11 @@
>       */
>      private $_overridePriority;
>  
> +       public function __construct($name) {
> +               parent::__construct($name);
> +               $this->requiresLayout = true;
> +       }
> +    
>          /**
>       * Set the ident of the syslog message.
>       *
> @@ -156,7 +161,12 @@
>          openlog($this->_ident, $this->_option, $this->_facility);
>          
>          $level   = $event->getLevel();
> -        $message = $event->getRenderedMessage();
> +        if(null == $this->layout) {
> +               $message = $event->getRenderedMessage();
> +        }
> +        else {
> +               $message = $this->layout->format($event);
> +        }
>          
>          // If the priority of a syslog message can be overridden by a value defined in the properties-file,
>          // use that value, else use the one that is defined in the code.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LOG4PHP-16) Patch for LoggerAppenderSyslog to use Layouts

Posted by "Knut Urdalen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4PHP-16?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Urdalen updated LOG4PHP-16:
--------------------------------

    Component/s: Code

> Patch for LoggerAppenderSyslog to use Layouts
> ---------------------------------------------
>
>                 Key: LOG4PHP-16
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-16
>             Project: Log4php
>          Issue Type: Improvement
>          Components: Code
>            Reporter: Gary Richardson
>            Priority: Minor
>             Fix For: 2.0
>
>         Attachments: LoggerAppenderSyslog.patch
>
>
> I noticed that LoggerAppenderSyslog seems to ignore layouts. I'm not sure if this is by design.
> The following patch causes LoggerAppenderSyslog to use layouts:
> Index: src/main/php/appenders/LoggerAppenderSyslog.php
> ===================================================================
> --- src/main/php/appenders/LoggerAppenderSyslog.php     (revision 677439)
> +++ src/main/php/appenders/LoggerAppenderSyslog.php     (working copy)
> @@ -86,6 +86,11 @@
>       */
>      private $_overridePriority;
>  
> +       public function __construct($name) {
> +               parent::__construct($name);
> +               $this->requiresLayout = true;
> +       }
> +    
>          /**
>       * Set the ident of the syslog message.
>       *
> @@ -156,7 +161,12 @@
>          openlog($this->_ident, $this->_option, $this->_facility);
>          
>          $level   = $event->getLevel();
> -        $message = $event->getRenderedMessage();
> +        if(null == $this->layout) {
> +               $message = $event->getRenderedMessage();
> +        }
> +        else {
> +               $message = $this->layout->format($event);
> +        }
>          
>          // If the priority of a syslog message can be overridden by a value defined in the properties-file,
>          // use that value, else use the one that is defined in the code.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LOG4PHP-16) Patch for LoggerAppenderSyslog to use Layouts

Posted by "Gary Richardson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4PHP-16?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Richardson updated LOG4PHP-16:
-----------------------------------

    Attachment: LoggerAppenderSyslog.patch

Jira flattened my copy and paste...

> Patch for LoggerAppenderSyslog to use Layouts
> ---------------------------------------------
>
>                 Key: LOG4PHP-16
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-16
>             Project: Log4php
>          Issue Type: Improvement
>            Reporter: Gary Richardson
>            Priority: Minor
>         Attachments: LoggerAppenderSyslog.patch
>
>
> I noticed that LoggerAppenderSyslog seems to ignore layouts. I'm not sure if this is by design.
> The following patch causes LoggerAppenderSyslog to use layouts:
> Index: src/main/php/appenders/LoggerAppenderSyslog.php
> ===================================================================
> --- src/main/php/appenders/LoggerAppenderSyslog.php     (revision 677439)
> +++ src/main/php/appenders/LoggerAppenderSyslog.php     (working copy)
> @@ -86,6 +86,11 @@
>       */
>      private $_overridePriority;
>  
> +       public function __construct($name) {
> +               parent::__construct($name);
> +               $this->requiresLayout = true;
> +       }
> +    
>          /**
>       * Set the ident of the syslog message.
>       *
> @@ -156,7 +161,12 @@
>          openlog($this->_ident, $this->_option, $this->_facility);
>          
>          $level   = $event->getLevel();
> -        $message = $event->getRenderedMessage();
> +        if(null == $this->layout) {
> +               $message = $event->getRenderedMessage();
> +        }
> +        else {
> +               $message = $this->layout->format($event);
> +        }
>          
>          // If the priority of a syslog message can be overridden by a value defined in the properties-file,
>          // use that value, else use the one that is defined in the code.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.