Reputation: 133
I have a system that get data (usually exe files and text files) from several service provider, and my system get this data and preform some work on it (basically analyse its behavior).
I'm using Log4Net
to generate log files and I would like to have separate log file for each service provider.
Until now (as I have only one service provider) I used Postsharp
to log / trace my system. Basically I created attributes that have this code in it:
Public class LogAttribute : OnMethodBoundaryAspect
{
private static ILog = LogManager.GetLogger();
public override void OnEntry(MethodExecutionEventArgs eventArgs)
{
//Log some stuff...
}
//some other code
}
And I add this ,or this kind of attributes (I have different attributes to different logging policies that I'm having) and I attached this attributes to different methods / assemblies that I want to log.
Question
Can I use Postsharp
to decode the relevant log file base on the service that use the method being logged? (some methods and classes being used by more then one service provider).
If it's help I'm using Autofac to inject my dependencies, so maybe I can resolve the the log in run-time?
Upvotes: 3
Views: 1135
Reputation: 6857
You can definitively choose a different log file according to the current class or namespace. I can't help you with Autofac or log4net but, regarding PostSharp, I would suggest to:
Upvotes: 1