So far I was using Apache Log4Net. To reduce the number of external libs I decided to use the logging built into ServiceStack. But my code-based configuration does not work, there are definitions missing!
public static void InitLogger(Level eventLogLevel, Level logFileLevel, int maxFileSizeInMb, bool filterNh)
var hierarchy = (Hierarchy) LogManager.GetRepository();
var topInLogger = LogManager.GetLogger(OpManConstants.LoggerName);
var topInProtocol = LogManager.GetLogger(OpManConstants.ProtLoggerName);
var topInvoiceLogger = (Logger) topInLogger.Logger;
var topInvoiceProtocolLogger = (Logger) topInProtocol.Logger;
Level is unknown and also
I have defined a
ColoredConsoleAppender but that one also has a lot of missing definitions, e.g.
ConversionPattern, and many more.
Do I have to install Apache Log4Net or do I miss something inside ServiceStack? I executed
Also I used to configure Log4Net in Program.cs BEFORE appHost.Init() was called.
ServiceStack Logging Providers provides a dependency-free abstraction over existing logging providers, but it doesn't reduce the number of external libs (it adds an additional one, the
ILog Log4Net adapter), i.e. you would still need to configure configure Log4Net as normal which if you've configured it in your Web.config/App.config you can initialize with:
LogManager.LogFactory = new Log4NetFactory(configureLog4Net:true);
Otherwise if you're maintaining the config in an external file you can specify it with:
LogManager.LogFactory = new Log4NetFactory("log4net.config");
How you configure Log4Net in code is still a Log4Net concern unrelated to ServiceStack, i.e. you would still need to include
log4net namespaces and use their classes to configure it, there's an example showing of this in StackOverflow.
Note: Installing ServiceStack.Logging.Log4Net does also install log4net so you wont need to install it separately.
Thanks for the clarification!