I have two classes(A,B) and multiple threads are running. and one global variable in Class B, i am creating object of class B from class A
B objB = new B(_istry);
_istry is global variable in Class A and get modifies based on input
in Class B constructor is like this
public B(bool istry)
{
IStry = istry;
}
so based on IStry
value i am writing logs in different file.
if (IStry==TRUE)
---normal file path like (C:\log.txt)---
else
---modified file path (C:\IStry\log.txt)
this i want to do through log4net but i am not getting how to change folder based on one variable dynamically.
.GetLogger
method in the constructor based on the variable. Slightly more involved is one logger with two appenders that filter based on an event property; this requires actually setting event properties, which means you have to explicitly construct events and can't use theILog
convenience methods. Alternatively, depending on the scope of what you're logging, aThreadContext
could be used to set the property. You could also filter by event message, if you're OK with changing that.