You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alec Swan <al...@gmail.com> on 2010/03/19 20:01:38 UTC

How to specify different log4j.properties for production and WicketTester servlet container?

We have WEB-INF/classes/log4j.properties file which instructs log4j to log
to ${catalina.home}/logs/${logFileName}.log file. This works great when I
deploy the web app in Tomcat.

However, I would like the logs to be written to a different file when I run
my tests that use WicketTester and start their own servlet containers. How
can I instruct my tests to log to a different location or even use a
different log4j.properties file altogether?

Thanks.

Re: How to specify different log4j.properties for production and WicketTester servlet container?

Posted by Alec Swan <al...@gmail.com>.
Changes to the test classpath suggested by Igor worked. I was under the
wrong impression that Wicket Tester was deploying my web app the same way it
is deployed in Tomcat in production and hence was always reading
WEB-INF/classes/log4j.properties.

On Fri, Mar 19, 2010 at 2:11 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> put another log4j.properties into your src/test/resources or
> src/test/java. since the test dirs are before the main dirs when tests
> run they will override log4j.properties in your src/main/resources or
> src/main/java
>
> -igor
>
> On Fri, Mar 19, 2010 at 12:59 PM, Alec Swan <al...@gmail.com> wrote:
> > Hi,
> >
> > It looks like the link you provided is temporarily down, but I am
> assuming
> > that your idea was to replace log4j.properties file with the one specific
> to
> > each maven profile.
> >
> > This is definitely an option, but I am have limited control over the
> build
> > file because it is generated by my NetBeans IDE.
> >
> > I wonder if there is a way to specify log4j.properties location
> > programmatically in the test code. Maybe somehow override the classpath
> of
> > Wicket Tester's servlet container?
> >
> > Thanks.
> >
> > Alec
> >
> > On Fri, Mar 19, 2010 at 1:17 PM, James Carman
> > <jc...@carmanconsulting.com>wrote:
> >
> >> You can look at how I set up configuration stuff in my Advanced Wicket
> >> example code:
> >>
> >> http://svn.carmanconsulting.com/public/wicket-advanced/trunk
> >>
> >> Basically, I use maven profiles to point to different configuration
> >> directories for each environment (dev, test, prod).  Perhaps that
> >> would help.
> >>
> >> On Fri, Mar 19, 2010 at 3:01 PM, Alec Swan <al...@gmail.com> wrote:
> >> > We have WEB-INF/classes/log4j.properties file which instructs log4j to
> >> log
> >> > to ${catalina.home}/logs/${logFileName}.log file. This works great
> when I
> >> > deploy the web app in Tomcat.
> >> >
> >> > However, I would like the logs to be written to a different file when
> I
> >> run
> >> > my tests that use WicketTester and start their own servlet containers.
> >> How
> >> > can I instruct my tests to log to a different location or even use a
> >> > different log4j.properties file altogether?
> >> >
> >> > Thanks.
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to specify different log4j.properties for production and WicketTester servlet container?

Posted by Igor Vaynberg <ig...@gmail.com>.
put another log4j.properties into your src/test/resources or
src/test/java. since the test dirs are before the main dirs when tests
run they will override log4j.properties in your src/main/resources or
src/main/java

-igor

On Fri, Mar 19, 2010 at 12:59 PM, Alec Swan <al...@gmail.com> wrote:
> Hi,
>
> It looks like the link you provided is temporarily down, but I am assuming
> that your idea was to replace log4j.properties file with the one specific to
> each maven profile.
>
> This is definitely an option, but I am have limited control over the build
> file because it is generated by my NetBeans IDE.
>
> I wonder if there is a way to specify log4j.properties location
> programmatically in the test code. Maybe somehow override the classpath of
> Wicket Tester's servlet container?
>
> Thanks.
>
> Alec
>
> On Fri, Mar 19, 2010 at 1:17 PM, James Carman
> <jc...@carmanconsulting.com>wrote:
>
>> You can look at how I set up configuration stuff in my Advanced Wicket
>> example code:
>>
>> http://svn.carmanconsulting.com/public/wicket-advanced/trunk
>>
>> Basically, I use maven profiles to point to different configuration
>> directories for each environment (dev, test, prod).  Perhaps that
>> would help.
>>
>> On Fri, Mar 19, 2010 at 3:01 PM, Alec Swan <al...@gmail.com> wrote:
>> > We have WEB-INF/classes/log4j.properties file which instructs log4j to
>> log
>> > to ${catalina.home}/logs/${logFileName}.log file. This works great when I
>> > deploy the web app in Tomcat.
>> >
>> > However, I would like the logs to be written to a different file when I
>> run
>> > my tests that use WicketTester and start their own servlet containers.
>> How
>> > can I instruct my tests to log to a different location or even use a
>> > different log4j.properties file altogether?
>> >
>> > Thanks.
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to specify different log4j.properties for production and WicketTester servlet container?

Posted by Alec Swan <al...@gmail.com>.
Hi,

It looks like the link you provided is temporarily down, but I am assuming
that your idea was to replace log4j.properties file with the one specific to
each maven profile.

This is definitely an option, but I am have limited control over the build
file because it is generated by my NetBeans IDE.

I wonder if there is a way to specify log4j.properties location
programmatically in the test code. Maybe somehow override the classpath of
Wicket Tester's servlet container?

Thanks.

Alec

On Fri, Mar 19, 2010 at 1:17 PM, James Carman
<jc...@carmanconsulting.com>wrote:

> You can look at how I set up configuration stuff in my Advanced Wicket
> example code:
>
> http://svn.carmanconsulting.com/public/wicket-advanced/trunk
>
> Basically, I use maven profiles to point to different configuration
> directories for each environment (dev, test, prod).  Perhaps that
> would help.
>
> On Fri, Mar 19, 2010 at 3:01 PM, Alec Swan <al...@gmail.com> wrote:
> > We have WEB-INF/classes/log4j.properties file which instructs log4j to
> log
> > to ${catalina.home}/logs/${logFileName}.log file. This works great when I
> > deploy the web app in Tomcat.
> >
> > However, I would like the logs to be written to a different file when I
> run
> > my tests that use WicketTester and start their own servlet containers.
> How
> > can I instruct my tests to log to a different location or even use a
> > different log4j.properties file altogether?
> >
> > Thanks.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to specify different log4j.properties for production and WicketTester servlet container?

Posted by James Carman <jc...@carmanconsulting.com>.
You can look at how I set up configuration stuff in my Advanced Wicket
example code:

http://svn.carmanconsulting.com/public/wicket-advanced/trunk

Basically, I use maven profiles to point to different configuration
directories for each environment (dev, test, prod).  Perhaps that
would help.

On Fri, Mar 19, 2010 at 3:01 PM, Alec Swan <al...@gmail.com> wrote:
> We have WEB-INF/classes/log4j.properties file which instructs log4j to log
> to ${catalina.home}/logs/${logFileName}.log file. This works great when I
> deploy the web app in Tomcat.
>
> However, I would like the logs to be written to a different file when I run
> my tests that use WicketTester and start their own servlet containers. How
> can I instruct my tests to log to a different location or even use a
> different log4j.properties file altogether?
>
> Thanks.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org