3 Replies Latest reply on Feb 6, 2013 11:17 AM by Tito ..

    Arquillian as7 slf4j debug doesn't work

    Tito .. Newbie


      I am developing a little project and I am testing rest services with Arquillian.


      My test class is like this:




      public class CustomerResourceRESTEasyClientTest {

          private static final String RESOURCE_PREFIX = JaxRsActivator.class.getAnnotation(ApplicationPath.class).value().substring(1);



          @Deployment(testable = false)

          public static WebArchive createDeployment() {

              return ShrinkWrap.create(WebArchive.class, "test.war").addPackages(true, "org.yukka.bloggo")

                      .addAsResource("test-persistence.xml", "META-INF/persistence.xml")

                      .addAsWebInfResource(EmptyAsset.INSTANCE, "log4j.xml");





          URL deploymentUrl;



          public static void initResteasyClient() {





          public void testInsertPost() throws Exception {

              PostRestService client = ProxyFactory.create(PostRestService.class, deploymentUrl.toString() + RESOURCE_PREFIX);

              Post post = new Post("title","content",new Date(System.currentTimeMillis()),new User("username","email"),new Blog(1L));

              Response response = client.insert(post);







      <?xml version="1.0" encoding="UTF-8" ?>

      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">



          <appender name="yukkaconsole" class="org.apache.log4j.ConsoleAppender">

              <layout class="org.apache.log4j.PatternLayout">

                  <!-- Print the date in ISO 8601 format -->

                  <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %p [%C:%L] - %m%n"/>



          <!--<appender name="AppLogAppender" class="org.apache.log4j.DailyRollingFileAppender">

              <param name="DatePattern" value="'.'yyyy-MM-dd"/>

              <param name="File" value="targe/MyAppLogsFile.log" />

              <param name="Append" value="false"/>

              <layout class="org.apache.log4j.PatternLayout">

                  <param name="ConversionPattern" value="%d [%t] %p - %m%n"/>



            <category name="org.yukka.bloggo">

              <priority value="DEBUG"/>

              <appender-ref ref="yukkaconsole"/>



              <priority value ="DEBUG"/>

              <appender-ref ref="yukkaconsole"/>





      And I call slf4j logger like this:



      import org.slf4j.Logger;

      import org.slf4j.LoggerFactory;


      private Logger logger = LoggerFactory.getLogger(getClass());


          PostManagerLocal postManager;




          public Response insert(Post post) {


                  logger.debug("Invoked insert with param: "+post);


                  Response response = Response.ok().build();

                  logger.debug("returning response with status: "+response.getStatus());

                  return response;

              }catch (RuntimeException e){

                  logger.error("Error creating post: ");


                  Response response = Response.serverError().build();

                  logger.debug("returning response with status: "+response.getStatus());

                  return response;






      The problem is that error calls, writes on the console, while debug calls don't write anything.

      I also tried activating the commented parts of the log4j.xml, the result is the same.

      Is there something wrong in the way I configure logging?

      Is something missing?

      Thanks for any help.


        • 1. Re: Arquillian as7 slf4j debug doesn't work
          Vineet Reynolds Apprentice

          I believe the problem lies with this statement in your deployment:


          .addAsWebInfResource(EmptyAsset.INSTANCE, "log4j.xml");


          That statement adds an empty log4j.xml file (EmptyAsset.INSTANCE) into your WEB-INF directory. You may need to reference the File as an Asset in your addAsWebInfResource call.

          • 2. Re: Arquillian as7 slf4j debug doesn't work
            Tito .. Newbie


            I modified with:


            .addAsWebInfResource(new FileAsset(new File("src/test/resources/log4j.xml")), "log4j.xml");


            Doesn't work yet

            • 3. Re: Arquillian as7 slf4j debug doesn't work
              Tito .. Newbie

              I found a workaround, that it's not the solution I was looking for, but it works.

              I added this to arquillian.xml:

              <property name="serverConfig">standalone-test.xml</property>


              then, I added this to pom.xml:


























              And, of course, I added in a custom standalone-test.xml the configuration for the log4j category.

              1 of 1 people found this helpful