You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Hanasaki JiJi <ha...@hanaden.com> on 2003/11/06 03:00:34 UTC

logging to 2 destinations

1. how can the same log output be sent to two syslogs and a file?

2. I am running JUnit and my Application.  They both use log4j
	Just running the application, all is logged in the
	expected file.

	When running tests, via JUnit, the JUnit test output
	ends up in the Application logs.

	How can this be separated to go to 2 diff files at
	test time?
-- 
=================================================================
= Management is doing things right; leadership is doing the     =
=       right things.    - Peter Drucker                        =
=_______________________________________________________________=
=     http://www.sun.com/service/sunps/jdc/javacenter.pdf       =
=  www.sun.com | www.javasoft.com | http://www.sun.com/sunone   =
=================================================================


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: logging to 2 destinations

Posted by Jacob Kjome <ho...@visi.com>.
Use two separate file appenders, each pointing to its own file 
(eg....  application.log and junit.log).  Then, I recommend that you define 
stuff in the <root> logger that you'd want for your most common logging 
activities;  probably the stuff going to application.log.  After that, 
define a logger for your junit tests.  Provide a reference to the junit 
appender, give it a level, and set additivity to "false" such as...

<logger name="test.com.mycompany.mypackage" additivity="false"><level 
value="debug"/><appender-ref ref="JUnitAppender"/></logger>

That will end up acting, essentially, as the <root> logger for your junit 
tests and you will have entirely separated logging for application and 
junit classes.

Jake


At 08:00 PM 11/5/2003 -0600, you wrote:
>1. how can the same log output be sent to two syslogs and a file?
>
>2. I am running JUnit and my Application.  They both use log4j
>         Just running the application, all is logged in the
>         expected file.
>
>         When running tests, via JUnit, the JUnit test output
>         ends up in the Application logs.
>
>         How can this be separated to go to 2 diff files at
>         test time?
>--
>=================================================================
>= Management is doing things right; leadership is doing the     =
>=       right things.    - Peter Drucker                        =
>=_______________________________________________________________=
>=     http://www.sun.com/service/sunps/jdc/javacenter.pdf       =
>=  www.sun.com | www.javasoft.com | http://www.sun.com/sunone   =
>=================================================================
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org