On Fri, Aug 16, 2013 at 7:54 PM, Gary Gregory <[email protected]>wrote:
> On Fri, Aug 16, 2013 at 6:21 PM, David Nault <[email protected] > > wrote: > >> Hi All, >> >> We're using Log4j in a webapp and are looking at migrating to Log4j 2. >> >> We'd like to continue writing our log files to a location under the >> webapp's context root -- that is, under the directory returned by >> ServletContext.getRealPath("/"). This works very well in our QA environment >> where multiple versions of the webapp are deployed to a single Tomcat >> server. >> >> I've written a Lookup plugin that maps "${web:rootDir}" to the desired >> path. The problem is that the plugin is ignored when parsing the config >> file, specifically the "filename" attribute of a "File" appender. The >> BaseConfiguration object seems to be using a StrSubstitutor with a default >> Interpolator that only knows about the "sys" and "env" prefixes. >> >> For what it's worth, the custom Lookup plugin works fine when used in a >> pattern layout string. >> >> Any thoughts on how to get the BaseConfiguration to use a custom Lookup >> plugin, or alternate ways to get the log files to appear under the webapp >> root? System properties aren't the solution since they are shared between >> webapps and we'd rather not return to the bad old days of using a different >> property for each webapp. >> >> Log4j 2 beta 8. >> >> > Any config item that is annotated with Log4j annotations has to be part of > Log4J's config dat file. I'm not not 100% sure, but I think you might have > to regenerate Log4J's config dat file. There might be a way to scan the CP > for additional code to scan... > Also: This might be a nice add-on to Log4j if you're willing to contribute it ;) Gary > > Gary > > > Thanks, >> David >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > > -- > E-Mail: [email protected] | [email protected] > Java Persistence with Hibernate, Second > Edition<http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory > -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
