Logger.SetLogWriter(new LogWriterFactory().Create()) and empty parameters

Topics: Logging Application Block
May 1, 2014 at 6:00 PM

We have recently upgraded from EntLib 5 to EntLib 6. Our listener definitions remain the same (except for version #) and we have verified that there are no errors displayed within the EntLib6 Configurator.

However, when initializing the Logger (ie: Logger.SetLogWriter(new LogWriterFactory().Create())), we receive a System.ArgumentException: "The argument cannot be empty. Parameter name: subjectLineEnder". Checking our configuration (again, this was validated by the EntLib 6 Configurator), we see that our email trace listener has no subjectLineEnder attribute. Adding it in with an empty value still throws the same exception, of course (the error states it cannot be empty).

The workaround is to set it to any character (ex: space)... however, it's not clear why this is required through code when the configurator indicates that the subjectLineEnder is not required. Is there some other way around this? Is there a fix? Are we doing something wrong?

May 6, 2014 at 4:51 AM
It looks like between version 5 and 6 some additional validation was added to not allow the subjectLineEnder to be null or empty. Actually, the validation was added for toAddress, fromAddress, subjectLineEnder, subjectLineStarter, and smtpServer. It's obvious why toAddress is required but I'm not so sure about the subjectLineEnder and subjectLineEnder.

I don't see another way around this so I think you've found the workaround (add a space).

I've created an issue on the logging site.

Randy Levy
Enterprise Library support engineer
Support How-to
May 6, 2014 at 1:20 PM
Thanks very much for looking into this and logging the issue, Randy.