Log4net
  1. Log4net
  2. LOG4NET-13

Allow SMTPAppender to have replaceable parameters in Subject

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.9
    • Fix Version/s: 1.2.10
    • Component/s: Appenders
    • Labels:
      None
    • Environment:
      From sourceforge - 749620 - Jeremy Wiebe - jeropa

      Description

      It would be helpful to be able to have parameters that
      are replaced on a per-log event basis on the Subject
      line for the SMTPAppender.

      Example:
      I have multiple web servers running a .NET web service
      and all use log4net. When an error occurs, they use the
      SMTPAppender to notify me. It would be very useful to
      include the host name of the sender in the subject line
      so that I could easily determine which web server had
      an error instead of having to look into the email.

      In thinking more about this it could either be the
      Subject line or the From line that has replacable
      parameters. Perhaps even make it so that these
      properties can use the <layout> tag.

      Jeremy Wiebe - jeropa

        Activity

        Nicko Cadell created issue -
        Hide
        Nicko Cadell added a comment -

        As the SmtpAppender sends a list of buffered events it would need to pick one event to use for pattern replacement. The From and Subject params could be changed to PatternLayout fields. Then any PatternLayout strings can be used to generate the From and Subject from the selected event.

        This would be a breaking change for apps that programmatically configure.

        Show
        Nicko Cadell added a comment - As the SmtpAppender sends a list of buffered events it would need to pick one event to use for pattern replacement. The From and Subject params could be changed to PatternLayout fields. Then any PatternLayout strings can be used to generate the From and Subject from the selected event. This would be a breaking change for apps that programmatically configure.
        Hide
        Nicko Cadell added a comment -

        There is an example appender in the SampleAppendersApp which sends a single event via SMTP email and allows replacable patterns in the email subject line.

        See:

        examples\net\1.0\Appenders\SampleAppendersApp\cs\src\Appender\SimpleSmtpAppender.cs

        Show
        Nicko Cadell added a comment - There is an example appender in the SampleAppendersApp which sends a single event via SMTP email and allows replacable patterns in the email subject line. See: examples\net\1.0\Appenders\SampleAppendersApp\cs\src\Appender\SimpleSmtpAppender.cs
        Nicko Cadell made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.2.10 [ 11128 ]
        Resolution Fixed [ 1 ]
        Nicko Cadell made changes -
        Summary Allow SMTPAppender to have replacable parameters in Subject Allow SMTPAppender to have replaceable parameters in Subject
        Description It would be helpful to be able to have parameters that
        are replaced on a per-log event basis on the Subject
        line for the SMTPAppender.

        Example:
        I have multiple web servers running a .NET web service
        and all use log4net. When an error occurs, they use the
        SMTPAppender to notify me. It would be very useful to
        include the host name of the sender in the subject line
        so that I could easily determine which web server had
        an error instead of having to look into the email.

        In thinking more about this it could either be the
        Subject line or the From line that has replacable
        parameters. Perhaps even make it so that these
        properties can use the <layout> tag.

        Jeremy Wiebe - jeropa
        It would be helpful to be able to have parameters that
        are replaced on a per-log event basis on the Subject
        line for the SMTPAppender.

        Example:
        I have multiple web servers running a .NET web service
        and all use log4net. When an error occurs, they use the
        SMTPAppender to notify me. It would be very useful to
        include the host name of the sender in the subject line
        so that I could easily determine which web server had
        an error instead of having to look into the email.

        In thinking more about this it could either be the
        Subject line or the From line that has replacable
        parameters. Perhaps even make it so that these
        properties can use the <layout> tag.

        Jeremy Wiebe - jeropa
        Hide
        rams.rapo added a comment -

        Hi,

        I have a similar need in Java application. Can the fix be propagated to log4j implementation for Java.
        I'm using log4j 1.2.15 and had no luck passing run time parameters in subject line set by MDC.

        <param name="Subject" value="Error from Application. Client IP - [%X

        {clientIP}

        ], Server IP - [%X

        {serverIP}

        ]" />

        Show
        rams.rapo added a comment - Hi, I have a similar need in Java application. Can the fix be propagated to log4j implementation for Java. I'm using log4j 1.2.15 and had no luck passing run time parameters in subject line set by MDC. <param name="Subject" value="Error from Application. Client IP - [%X {clientIP} ], Server IP - [%X {serverIP} ]" />
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        181d 23h 33m 1 Nicko Cadell 30/Aug/05 08:44

          People

          • Assignee:
            Unassigned
            Reporter:
            Nicko Cadell
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development