Log4net
  1. Log4net
  2. LOG4NET-87

Support ASP.Net related PatternConverters to allow items from the HttpContext.Current.Session, Cache, Request, etc. to be captured.

    Details

    • Type: Wish Wish
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2.11
    • Component/s: Core
    • Labels:
      None

      Description

      It would be nice if there were built-in Pattern Converters to support core ASP.Net objects:

      %aspnet-session

      {UserId}

      %aspnet-session
      %aspnet-request

      {ProductId}

      This issue may be a good time to investigate supporting a more advanced syntax for the Option parameter:

      %aspnet-request

      {queryString:ProductId}

      that could be shared across all Pattern Converters.

        Activity

        Hide
        Nicko Cadell added a comment -

        Gert,

        I think these patterns are a very god idea. I have a few suggestions on how to polish them up for release:

        The copyright year in the file header should reflect the years when the file contents is edited, i.e. for the new files it should be 2006.

        All classes and methods should have user level comments. See other pattern files for examples.

        The new patterns added to the PatternLayout should be documented in detail in the PatternLayout <remarks> section.

        Is there any reason why you have not added a pattern for the AspNetSessionPatternConverter? aspnet-session?

        The System.Web library isn't available on all platforms, you will need to exclude your new patterns from the build, and from the PatternLayout:

        // .NET Compact Framework 1.0 has no support for ASP.NET
        // SSCLI 1.0 has no support for ASP.NET
        #if !NETCF && !SSCLI

        Show
        Nicko Cadell added a comment - Gert, I think these patterns are a very god idea. I have a few suggestions on how to polish them up for release: The copyright year in the file header should reflect the years when the file contents is edited, i.e. for the new files it should be 2006. All classes and methods should have user level comments. See other pattern files for examples. The new patterns added to the PatternLayout should be documented in detail in the PatternLayout <remarks> section. Is there any reason why you have not added a pattern for the AspNetSessionPatternConverter? aspnet-session? The System.Web library isn't available on all platforms, you will need to exclude your new patterns from the build, and from the PatternLayout: // .NET Compact Framework 1.0 has no support for ASP.NET // SSCLI 1.0 has no support for ASP.NET #if !NETCF && !SSCLI
        Hide
        Stefan Bodewig added a comment -

        What is needed to close this?

        [for those who like me just look at the comment thread rather than the linked subversion commits, Ron has already implemented the ideas]

        Show
        Stefan Bodewig added a comment - What is needed to close this? [for those who like me just look at the comment thread rather than the linked subversion commits, Ron has already implemented the ideas]
        Hide
        Stefan Bodewig added a comment -

        just missing some documentation

        Show
        Stefan Bodewig added a comment - just missing some documentation
        Hide
        Stefan Bodewig added a comment -

        Missing documentation added with svn revision 1173186

        Show
        Stefan Bodewig added a comment - Missing documentation added with svn revision 1173186
        Hide
        Martin Meixger added a comment -

        combining the AspNetPatternLayoutConverter with AsyncAppender doesn't work, because there is no more HttpContext.Current available when the AsyncAppender renders the message

        Show
        Martin Meixger added a comment - combining the AspNetPatternLayoutConverter with AsyncAppender doesn't work, because there is no more HttpContext.Current available when the AsyncAppender renders the message
        Hide
        Ron Grabowski added a comment -

        Have you tried fixing the fields before sending data to another thread?

        http://logging.apache.org/log4net/release/sdk/log4net.Core.FixFlags.html

        You'll probably need to tweak your appender to evaluate the values before sending to another thread. Take a look at BufferingAppenderSkeleton's Fix property:

        http://logging.apache.org/log4net/release/sdk/log4net.Appender.BufferingAppenderSkeleton.Fix.html

        Hopefully its degrading gracefully.

        Show
        Ron Grabowski added a comment - Have you tried fixing the fields before sending data to another thread? http://logging.apache.org/log4net/release/sdk/log4net.Core.FixFlags.html You'll probably need to tweak your appender to evaluate the values before sending to another thread. Take a look at BufferingAppenderSkeleton's Fix property: http://logging.apache.org/log4net/release/sdk/log4net.Appender.BufferingAppenderSkeleton.Fix.html Hopefully its degrading gracefully.
        Hide
        Martin Meixger added a comment -

        The AspNetPatternLayoutConverter retrieves the HttpContext.Current properties only when the LoggingEvent gets rendered via Format().

        Unforunately this is much later and in another thread as the fixing of the fields and ThreadProperties.

        I see no other way than copying the interested HttpContext properties manually into the ThreadProperties.

        Show
        Martin Meixger added a comment - The AspNetPatternLayoutConverter retrieves the HttpContext.Current properties only when the LoggingEvent gets rendered via Format(). Unforunately this is much later and in another thread as the fixing of the fields and ThreadProperties. I see no other way than copying the interested HttpContext properties manually into the ThreadProperties.

          People

          • Assignee:
            Ron Grabowski
            Reporter:
            Ron Grabowski
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development