I want to create a (shared) correlation ID for calls to my application
(ASP.NET MVC and/or WCF-hosted services).
I have tried with a custom LoggingFactory:
public class CorrelationLoggerFactory :
> Castle.Services.Logging.Log4netIntegration.ExtendedLog4netFactory
> {
> public const string CorrelationIdProperty = "CorrelationID";
>
> public override IExtendedLogger Create(string name)
> {
> var logger = base.Create(name);
>
> var corrId = logger.ThreadProperties[CorrelationIdProperty] as
> Guid?;
> if (corrId == null)
> {
> corrId = Guid.NewGuid();
> logger.ThreadProperties[CorrelationIdProperty] =
> corrId.Value;
> }
>
> return logger;
> }
> }
>
This seems to work - except I haven't been able to output the correlation
ID, but I guess that's just a problem with my Log4Net pattern layout.
However, doesn't IIS reuse threads?
In that case, I'm afraid correlation ID's could be reused.
What would be the correct place to clear the property?
Thanks,
Marvin
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/groups/opt_out.