List Info

Thread: Created: (LOG4NET-129) EventLogAppender EventID parsing does not handle Active Properties pro




Created: (LOG4NET-129) EventLogAppender EventID parsing does not handle Active Properties pro
country flaguser name
United States
2007-12-13 05:55:43
EventLogAppender EventID parsing does not handle Active
Properties properly
------------------------------------------------------------
---------------

                 Key: LOG4NET-129
                 URL: htt
ps://issues.apache.org/jira/browse/LOG4NET-129
             Project: Log4net
          Issue Type: Bug
          Components: Appenders
    Affects Versions: 1.2.10, 1.2.11
            Reporter: Michael Christensen
            Priority: Minor


The EventLogAppender supports setting the EventID of the
Event being logged through Context Properties, as described
here:
http://www.m
ail-archive.com/log4net-userlogging.apache.org/msg02396.html

However, since GlobalContext is inappropriate for storing
the EventID (as it is likely to be specific for any given
individual call to Log) and ThreadContext cannot be used
reliably when running in the context of ASP.NET (since
ASP.NET might switch the request between threads during
execution, as outlined here: http://piers7.blogspot.com/2005/12/l
og4net-context-problems-with-aspnet.html ), it would be
nice to be able to use an Active Property instead (which
could, for instance, delegate calls for the EventID to data
stored in HttpContext)

Unfortunately, this does not work, since the
EventLogAppender assumes that the Context Property holding
the EventID is either int or string. The relevant code is
found in EventLogAppender.cs, in the override protected void
Append(LoggingEvent loggingEvent) method:

if (eventIDPropertyObj is int)
{
	eventID = (int)eventIDPropertyObj;
}
else
{
	string eventIDPropertyString = eventIDPropertyObj as
string;
}

Any Active Property object will end up as null through the
"as string" call, and be ignored.

Suggested naive fix: If eventIDPropertyString is non-null
and of other type than int or string, call ToString() on the
object and TryParse as int. Or use whatever handling of
Active Properties found elsewhere in log4net.

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


Updated: (LOG4NET-129) EventLogAppender EventID parsing does not handle Active Properties pro
country flaguser name
United States
2007-12-31 15:16:43
     [ https://issues.apache.org/jira/browse/LOG4NET-129?page=co
m.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ron Grabowski updated LOG4NET-129:
----------------------------------

    Attachment: EventLogAppender.patch

Changed:

 string eventIDPropertyString = eventIDPropertyObj as
string;

to:

 string eventIDPropertyString;
 if (eventIDPropertyObj is string)
 {
  eventIDPropertyString = (string)eventIDPropertyObj;
 }
 else
 {
  eventIDPropertyString = eventIDPropertyObj.ToString();
 }

> EventLogAppender EventID parsing does not handle Active
Properties properly
>
------------------------------------------------------------
---------------
>
>                 Key: LOG4NET-129
>                 URL: htt
ps://issues.apache.org/jira/browse/LOG4NET-129
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.10, 1.2.11
>            Reporter: Michael Christensen
>            Priority: Minor
>         Attachments: EventLogAppender.patch
>
>
> The EventLogAppender supports setting the EventID of
the Event being logged through Context Properties, as
described here:
> http://www.m
ail-archive.com/log4net-userlogging.apache.org/msg02396.html
> However, since GlobalContext is inappropriate for
storing the EventID (as it is likely to be specific for any
given individual call to Log) and ThreadContext cannot be
used reliably when running in the context of ASP.NET (since
ASP.NET might switch the request between threads during
execution, as outlined here: http://piers7.blogspot.com/2005/12/l
og4net-context-problems-with-aspnet.html ), it would be
nice to be able to use an Active Property instead (which
could, for instance, delegate calls for the EventID to data
stored in HttpContext)
> Unfortunately, this does not work, since the
EventLogAppender assumes that the Context Property holding
the EventID is either int or string. The relevant code is
found in EventLogAppender.cs, in the override protected void
Append(LoggingEvent loggingEvent) method:
> if (eventIDPropertyObj is int)
> {
> 	eventID = (int)eventIDPropertyObj;
> }
> else
> {
> 	string eventIDPropertyString = eventIDPropertyObj as
string;
> }
> Any Active Property object will end up as null through
the "as string" call, and be ignored.
> Suggested naive fix: If eventIDPropertyString is
non-null and of other type than int or string, call
ToString() on the object and TryParse as int. Or use
whatever handling of Active Properties found elsewhere in
log4net.

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


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )