a few more follow up changes in 1.11

pull/4/head v1.11
Kohsuke Kawaguchi 2011-10-27 11:21:11 -07:00
parent c2ee1d585d
commit 98a12b70ff
1 changed files with 8 additions and 3 deletions

View File

@ -233,7 +233,7 @@ namespace winsw
{ {
get get
{ {
string mode; string mode=null;
// first, backward compatibility with older configuration // first, backward compatibility with older configuration
XmlElement e = (XmlElement)dom.SelectSingleNode("//logmode"); XmlElement e = (XmlElement)dom.SelectSingleNode("//logmode");
@ -242,9 +242,12 @@ namespace winsw
} else { } else {
// this is more modern way, to support nested elements as configuration // this is more modern way, to support nested elements as configuration
e = (XmlElement)dom.SelectSingleNode("//log"); e = (XmlElement)dom.SelectSingleNode("//log");
mode = e.GetAttribute("mode"); if (e!=null)
mode = e.GetAttribute("mode");
} }
if (mode == null) mode = "append";
switch (mode) switch (mode)
{ {
case "rotate": case "rotate":
@ -272,8 +275,10 @@ namespace winsw
return new SizeBasedRollingLogAppender(LogDirectory, BaseName, sizeThreshold, keepFiles); return new SizeBasedRollingLogAppender(LogDirectory, BaseName, sizeThreshold, keepFiles);
case "append": case "append":
default:
return new DefaultLogAppender(LogDirectory, BaseName); return new DefaultLogAppender(LogDirectory, BaseName);
default:
throw new InvalidDataException("Undefined logging mode: " + mode);
} }
} }