[ http://issues.apache.org/jira/browse/LOG4NET-30?page=comments#action_12331455 ]
Ron Grabowski commented on LOG4NET-30: -------------------------------------- This may be a solution: http://www.mail-archive.com/log4net-dev%40logging.apache.org/msg01070.html " The ${foo} notation searches the environment for a key and uses its value. I wonder if it would be useful to introduce the idea of a local environment that would allow locally scoped temporary environment variables: <log4net> <localEnvironment name="LOG4NET_PATH" value="c:\logs\staging" /> <localEnvironment name="DEFAULT_LAYOUT" value="%message%newline" /> <appender name="FileAppender" type="log4net.Appender.FileAppender"> <file value="${LOG4NET_PATH}\log.txt" /> <layout type="log4net.Layout.PatternLayout" value="${DEFAULT_LAYOUT}" /> </appender> If the item was not found in the local environment, System.Environment would be searched. " > Add support for type aliases in config file > ------------------------------------------- > > Key: LOG4NET-30 > URL: http://issues.apache.org/jira/browse/LOG4NET-30 > Project: Log4net > Type: New Feature > Reporter: Ron Grabowski > Priority: Trivial > > 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. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
