[ https://issues.apache.org/jira/browse/LOG4NET-30?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stefan Bodewig updated LOG4NET-30: ---------------------------------- Fix Version/s: 1.2 Maintenance Release > Add support for type aliases in config file > ------------------------------------------- > > Key: LOG4NET-30 > URL: https://issues.apache.org/jira/browse/LOG4NET-30 > Project: Log4net > Issue Type: New Feature > Reporter: Ron Grabowski > Priority: Trivial > Fix For: 1.2 Maintenance Release > > > IBatisNet uses "type" attributes in their xml config files: > type="Company.Project.Foo.Data.Entity.Product, Company.Project.Data" > type="Company.Project.Foo.Data.Entity.Category, Company.Project.Data" > type="Company.Project.Foo.Data.Entity.User, Company.Project.Data" > to save the user from having to re-type long strings every time something > references a Product, Category, etc. They define an <alias> node that > contains <typeAlias> entries: > <alias> > <typeAlias alias="Product" type="Company.Project.Foo.Data.Entity.Product, > Company.Project.Data" /> > <typeAlias alias="Category" type="Company.Project.Foo.Data.Entity.Product, > Company.Project.Data" /> > <typeAlias alias="User" type="Company.Project.Foo.Data.Entity.Product, > Company.Project.Data" /> > </alias> > Wherever I have to specify a type, I may use one of the aliases I defined at > the top of the file. > It would be nice if log4net supported a similiar concept. It would also be > nice if log4net shipped with some default aliases. I think normal casing > would be ok: > FileAppender -> log4net.Appender.FileAppender > An example incorporating the above suggestions would be (this will probably > wrap when it posts to the mailing list): > <alias> > <typeAlias alias="SessionContextPatternConverter" > type="log4netAspExtensions.SessionContextPatternConverter, > log4netAspExtensions" /> > <typeAlias alias="CacheContextPatternConverter" > type="log4netAspExtensions.CacheContextPatternConverter, > log4netAspExtensions" /> > <typeAlias alias="RequestContextPatternConverter" > type="log4netAspExtensions.RequestContextPatternConverter, > log4netAspExtensions" /> > <typeAlias alias="ApplicationContextPatternConverter" > type="log4netAspExtensions.ApplicationContextPatternConverter, > log4netAspExtensions" /> > </alias> > <appender name="LoginFileAppender" type="FileAppender"> > <file value="c:/inetpub/wwwroot/Logs/Logins.txt" /> > <layout type="PatternLayout"> > <converter> > <name value="asp-session" /> > <type value="SessionContextPatternConverter" /> > </converter> > <conversionPattern value="%5p %d (%c:%L) - [%asp-session{UserId}] %m%n" /> > </layout> > </appender> > I haven't fully looked into the <convertor> node to see if it can support > this style of attributes but an even shorted syntax might be: > <appender name="LoginFileAppender" type="FileAppender"> > <file value="c:/inetpub/wwwroot/Logs/Logins.txt" /> > <layout type="PatternLayout"> > <converter name="asp-session" type="SessionContextPatternConverter" /> > <conversionPattern value="%5p %d (%c:%L) - [%asp-session{UserId}] %m%n" /> > </layout> > </appender> > It should be possible to overwrite the builtin aliases. Had I overridden > FileAppender: > <typeAlias alias="FileAppender" > type="log4netAspExtensions.AspNetFileAppender, log4netAspExtensions" /> > I would be able to declare my appender with support for the ~ character: > <appender name="LoginFileAppender" type="FileAppender"> > <file value="~/Logs/Login.txt" /> > <layout type="PatternLayout"> > <converter name="asp-session" type="SessionContextPatternConverter" /> > <conversionPattern value="%5p %d (%c:%L) - [%asp-session{UserId}] %m%n" /> > </layout> > </appender> > I think that the above changes would descrease the size of the config file > and increase the files readability. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira