log4net initialisierung im code. nützlich wenn man schnell nen logger brauch und log4net verwenden kann.
string loggerConfigXml =
"<log4net>"
+ "<appender name=\"Appender\" type=\"log4net.Appender.ConsoleAppender\">"
+ "<layout type=\"log4net.Layout.PatternLayout\">"
+ "<conversionPattern value=\"[%date][%logger]: %message %newline \" />"
+ "</layout>"
+ "</appender>"
+ "<root>"
+ "<level value=\"DEBUG\" />"
+ "<appender-ref ref=\"Appender\" />"
+ "</root>"
+ "</log4net>";
MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(loggerConfigXml));
log4net.Config.XmlConfigurator.Configure(ms);
log4net.ILog _testLogger = LogManager.GetLogger("Test");
Kommentare zum Snippet