1 year ago
#342144
David Thielen
log4net how best can I select just some logging in a class?
log4net does great on turning log levels on/off on a per class basis. But I have a case where I am implementing an interface and I have a ton of logging in this implementation. It's a 3rd party interface so I'm stuck having all this code, and hence all this logging, in a single class.
I've looked at creating helper classes for each of the areas of this implementation. But that actually makes things more messy. Partial classes work great for this, but again - still all one class.
Is there a good way to further specify which logging statements to log? The best I've come up with is an enum of the categories in the class and define each logging statement with the specific enum. And then use that enum in the if (log.IsDebugEnable && MyEnum == true)
Anything better?
Update: per the request below, actually showing all this would be so long/large that no one would read it. So here's a summation:
log.Debug("order placed");
// ...
log.Debug("new stock added");
// ...
log.Debug("price change");
// ...
log.Debug("order changed");
// ...
log.Debug("predicted price");
// ...
log.Debug("profit taken");
// ... the types of actions go on and on
All of the above is implementing a QCAlgorithm in QuantConnect. Basically there are times I want the details for orders logged. Other times I don't want those but do need to log the predicted price and actual price logging.
log4net
0 Answers
Your Answer