You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by Timothy Farkas <tf...@mapr.com> on 2018/05/25 00:14:34 UTC

[Question] Using loggers in tests

Hi All,

I was wondering if there was a magical way to enable the Slf4j loggers for unit tests without adding a logback-test.xml file into src/test/resources for a submodule in the project? If not, would there by any issues with adding a default logback-test.xml file that has logging disabled by default to each submodule's src/test/resources directory? I'd like to do this in order to discourage the use of System.out.println in tests (and eventually prohibit it completely) by providing an easy to use out of the box alternative. Currently our test logs are polluted by many System.out.print statements and switching to using logging will allow us to have our test messages when we want them, and to disable them when we don't want them.

Thanks,
Tim

Re: [Question] Using loggers in tests

Posted by Paul Rogers <pa...@yahoo.com.INVALID>.
Right. Then the LogFixture selectively enables logging to stdout for those loggers of use to that test, and turns that logging back off after the test runs.
Thanks,
- Paul

 

    On Friday, May 25, 2018, 11:35:45 AM PDT, Sorabh Hamirwasia <sh...@mapr.com> wrote:  
 
 I think by default the logging is disabled except for error message which is directed to stdout. All other logging are directed to socket appender consumed by Lilith (if setup is there) when the property drill.lilith.enable is set to true.


Thanks,
Sorabh

________________________________
From: Timothy Farkas <tf...@mapr.com>
Sent: Friday, May 25, 2018 10:55:06 AM
To: dev@drill.apache.org
Subject: Re: [Question] Using loggers in tests

Thanks Vova,

I saw the logback-test.xml in drill-common, but logging messages won't print in the unit tests in java-exec unless I copy logback-test.xml to exec/java-exec/src/test/resources. Was I missing something?

Thanks,
Tim

________________________________
From: Vova Vysotskyi <vv...@gmail.com>
Sent: Friday, May 25, 2018 2:03:01 AM
To: dev@drill.apache.org
Subject: Re: [Question] Using loggers in tests

Hi Tim,

Drill already contains logback-test.xml file in drill-common module.
Since this module is used in all other modules, there is no need to add
more logback-test.xml files.

Kind regards,
Volodymyr Vysotskyi


пт, 25 трав. 2018 о 06:05 Timothy Farkas <tf...@mapr.com> пише:

> Thanks Paul, forgot about that. I'll migrate all the tests off of
> System.out.print and onto LogFixture, I don't think its worth it to create
> a TestLogger.out since we should all be using loggers anyway. I'll also add
> a checkstyle check that will cause the build to fail of System.out.print is
> used anywhere.
>
> Thanks,
> Tim
>
> ________________________________
> From: Paul Rogers <pa...@yahoo.com.INVALID>
> Sent: Thursday, May 24, 2018 7:08:28 PM
> To: dev@drill.apache.org
> Subject: Re: [Question] Using loggers in tests
>
> LogFixture? As illustrated in ExampleTest?
>
> This fixture lets you turn on all or selected loggers for the duration of
> a single test. I used it all the time when debugging. Works great.
> It works when turning loggers on when the default is that they are off.
> For whatever reason, I could not get it to work to turn off logging that
> was enabled in the config file.
> At one point I did look into adding a custom debug logger that works just
> like System.out, but is disabled by default. That way, conversion was just
> a matter of replacing System.out with TestLogger.out which can be done via
> search/replace. Not sure if I ever checked that in, but it would be trivial
> to replicate.
> Thanks,
> - Paul
>
>
>
>    On Thursday, May 24, 2018, 5:32:49 PM PDT, Timothy Farkas <
> tfarkas@mapr.com> wrote:
>
>  Hi All,
>
> I was wondering if there was a magical way to enable the Slf4j loggers for
> unit tests without adding a logback-test.xml file into src/test/resources
> for a submodule in the project? If not, would there by any issues with
> adding a default logback-test.xml file that has logging disabled by default
> to each submodule's src/test/resources directory? I'd like to do this in
> order to discourage the use of System.out.println in tests (and eventually
> prohibit it completely) by providing an easy to use out of the box
> alternative. Currently our test logs are polluted by many System.out.print
> statements and switching to using logging will allow us to have our test
> messages when we want them, and to disable them when we don't want them.
>
> Thanks,
> Tim
>  

Re: [Question] Using loggers in tests

Posted by Timothy Farkas <tf...@mapr.com>.
Thanks for the pointers Sorabh / Vova,

I was able to get lilith running and displaying test logs out of the box. Paul's LogFixture is also a good and easy to use alternative if we want to enable logs to print to the console. Since we have several good options for enabling the logs in the tests, I'll proceed with removing unnecessary System.out.prints and converting them into log statements where appropriate.

Thanks,
Tim

________________________________
From: Sorabh Hamirwasia <sh...@mapr.com>
Sent: Friday, May 25, 2018 11:35:30 AM
To: dev@drill.apache.org
Subject: Re: [Question] Using loggers in tests

I think by default the logging is disabled except for error message which is directed to stdout. All other logging are directed to socket appender consumed by Lilith (if setup is there) when the property drill.lilith.enable is set to true.


Thanks,
Sorabh

________________________________
From: Timothy Farkas <tf...@mapr.com>
Sent: Friday, May 25, 2018 10:55:06 AM
To: dev@drill.apache.org
Subject: Re: [Question] Using loggers in tests

Thanks Vova,

I saw the logback-test.xml in drill-common, but logging messages won't print in the unit tests in java-exec unless I copy logback-test.xml to exec/java-exec/src/test/resources. Was I missing something?

Thanks,
Tim

________________________________
From: Vova Vysotskyi <vv...@gmail.com>
Sent: Friday, May 25, 2018 2:03:01 AM
To: dev@drill.apache.org
Subject: Re: [Question] Using loggers in tests

Hi Tim,

Drill already contains logback-test.xml file in drill-common module.
Since this module is used in all other modules, there is no need to add
more logback-test.xml files.

Kind regards,
Volodymyr Vysotskyi


пт, 25 трав. 2018 о 06:05 Timothy Farkas <tf...@mapr.com> пише:

> Thanks Paul, forgot about that. I'll migrate all the tests off of
> System.out.print and onto LogFixture, I don't think its worth it to create
> a TestLogger.out since we should all be using loggers anyway. I'll also add
> a checkstyle check that will cause the build to fail of System.out.print is
> used anywhere.
>
> Thanks,
> Tim
>
> ________________________________
> From: Paul Rogers <pa...@yahoo.com.INVALID>
> Sent: Thursday, May 24, 2018 7:08:28 PM
> To: dev@drill.apache.org
> Subject: Re: [Question] Using loggers in tests
>
> LogFixture? As illustrated in ExampleTest?
>
> This fixture lets you turn on all or selected loggers for the duration of
> a single test. I used it all the time when debugging. Works great.
> It works when turning loggers on when the default is that they are off.
> For whatever reason, I could not get it to work to turn off logging that
> was enabled in the config file.
> At one point I did look into adding a custom debug logger that works just
> like System.out, but is disabled by default. That way, conversion was just
> a matter of replacing System.out with TestLogger.out which can be done via
> search/replace. Not sure if I ever checked that in, but it would be trivial
> to replicate.
> Thanks,
> - Paul
>
>
>
>     On Thursday, May 24, 2018, 5:32:49 PM PDT, Timothy Farkas <
> tfarkas@mapr.com> wrote:
>
>  Hi All,
>
> I was wondering if there was a magical way to enable the Slf4j loggers for
> unit tests without adding a logback-test.xml file into src/test/resources
> for a submodule in the project? If not, would there by any issues with
> adding a default logback-test.xml file that has logging disabled by default
> to each submodule's src/test/resources directory? I'd like to do this in
> order to discourage the use of System.out.println in tests (and eventually
> prohibit it completely) by providing an easy to use out of the box
> alternative. Currently our test logs are polluted by many System.out.print
> statements and switching to using logging will allow us to have our test
> messages when we want them, and to disable them when we don't want them.
>
> Thanks,
> Tim
>

Re: [Question] Using loggers in tests

Posted by Sorabh Hamirwasia <sh...@mapr.com>.
I think by default the logging is disabled except for error message which is directed to stdout. All other logging are directed to socket appender consumed by Lilith (if setup is there) when the property drill.lilith.enable is set to true.


Thanks,
Sorabh

________________________________
From: Timothy Farkas <tf...@mapr.com>
Sent: Friday, May 25, 2018 10:55:06 AM
To: dev@drill.apache.org
Subject: Re: [Question] Using loggers in tests

Thanks Vova,

I saw the logback-test.xml in drill-common, but logging messages won't print in the unit tests in java-exec unless I copy logback-test.xml to exec/java-exec/src/test/resources. Was I missing something?

Thanks,
Tim

________________________________
From: Vova Vysotskyi <vv...@gmail.com>
Sent: Friday, May 25, 2018 2:03:01 AM
To: dev@drill.apache.org
Subject: Re: [Question] Using loggers in tests

Hi Tim,

Drill already contains logback-test.xml file in drill-common module.
Since this module is used in all other modules, there is no need to add
more logback-test.xml files.

Kind regards,
Volodymyr Vysotskyi


пт, 25 трав. 2018 о 06:05 Timothy Farkas <tf...@mapr.com> пише:

> Thanks Paul, forgot about that. I'll migrate all the tests off of
> System.out.print and onto LogFixture, I don't think its worth it to create
> a TestLogger.out since we should all be using loggers anyway. I'll also add
> a checkstyle check that will cause the build to fail of System.out.print is
> used anywhere.
>
> Thanks,
> Tim
>
> ________________________________
> From: Paul Rogers <pa...@yahoo.com.INVALID>
> Sent: Thursday, May 24, 2018 7:08:28 PM
> To: dev@drill.apache.org
> Subject: Re: [Question] Using loggers in tests
>
> LogFixture? As illustrated in ExampleTest?
>
> This fixture lets you turn on all or selected loggers for the duration of
> a single test. I used it all the time when debugging. Works great.
> It works when turning loggers on when the default is that they are off.
> For whatever reason, I could not get it to work to turn off logging that
> was enabled in the config file.
> At one point I did look into adding a custom debug logger that works just
> like System.out, but is disabled by default. That way, conversion was just
> a matter of replacing System.out with TestLogger.out which can be done via
> search/replace. Not sure if I ever checked that in, but it would be trivial
> to replicate.
> Thanks,
> - Paul
>
>
>
>     On Thursday, May 24, 2018, 5:32:49 PM PDT, Timothy Farkas <
> tfarkas@mapr.com> wrote:
>
>  Hi All,
>
> I was wondering if there was a magical way to enable the Slf4j loggers for
> unit tests without adding a logback-test.xml file into src/test/resources
> for a submodule in the project? If not, would there by any issues with
> adding a default logback-test.xml file that has logging disabled by default
> to each submodule's src/test/resources directory? I'd like to do this in
> order to discourage the use of System.out.println in tests (and eventually
> prohibit it completely) by providing an easy to use out of the box
> alternative. Currently our test logs are polluted by many System.out.print
> statements and switching to using logging will allow us to have our test
> messages when we want them, and to disable them when we don't want them.
>
> Thanks,
> Tim
>

Re: [Question] Using loggers in tests

Posted by Timothy Farkas <tf...@mapr.com>.
Thanks Vova,

I saw the logback-test.xml in drill-common, but logging messages won't print in the unit tests in java-exec unless I copy logback-test.xml to exec/java-exec/src/test/resources. Was I missing something?

Thanks,
Tim

________________________________
From: Vova Vysotskyi <vv...@gmail.com>
Sent: Friday, May 25, 2018 2:03:01 AM
To: dev@drill.apache.org
Subject: Re: [Question] Using loggers in tests

Hi Tim,

Drill already contains logback-test.xml file in drill-common module.
Since this module is used in all other modules, there is no need to add
more logback-test.xml files.

Kind regards,
Volodymyr Vysotskyi


пт, 25 трав. 2018 о 06:05 Timothy Farkas <tf...@mapr.com> пише:

> Thanks Paul, forgot about that. I'll migrate all the tests off of
> System.out.print and onto LogFixture, I don't think its worth it to create
> a TestLogger.out since we should all be using loggers anyway. I'll also add
> a checkstyle check that will cause the build to fail of System.out.print is
> used anywhere.
>
> Thanks,
> Tim
>
> ________________________________
> From: Paul Rogers <pa...@yahoo.com.INVALID>
> Sent: Thursday, May 24, 2018 7:08:28 PM
> To: dev@drill.apache.org
> Subject: Re: [Question] Using loggers in tests
>
> LogFixture? As illustrated in ExampleTest?
>
> This fixture lets you turn on all or selected loggers for the duration of
> a single test. I used it all the time when debugging. Works great.
> It works when turning loggers on when the default is that they are off.
> For whatever reason, I could not get it to work to turn off logging that
> was enabled in the config file.
> At one point I did look into adding a custom debug logger that works just
> like System.out, but is disabled by default. That way, conversion was just
> a matter of replacing System.out with TestLogger.out which can be done via
> search/replace. Not sure if I ever checked that in, but it would be trivial
> to replicate.
> Thanks,
> - Paul
>
>
>
>     On Thursday, May 24, 2018, 5:32:49 PM PDT, Timothy Farkas <
> tfarkas@mapr.com> wrote:
>
>  Hi All,
>
> I was wondering if there was a magical way to enable the Slf4j loggers for
> unit tests without adding a logback-test.xml file into src/test/resources
> for a submodule in the project? If not, would there by any issues with
> adding a default logback-test.xml file that has logging disabled by default
> to each submodule's src/test/resources directory? I'd like to do this in
> order to discourage the use of System.out.println in tests (and eventually
> prohibit it completely) by providing an easy to use out of the box
> alternative. Currently our test logs are polluted by many System.out.print
> statements and switching to using logging will allow us to have our test
> messages when we want them, and to disable them when we don't want them.
>
> Thanks,
> Tim
>

Re: [Question] Using loggers in tests

Posted by Vova Vysotskyi <vv...@gmail.com>.
Hi Tim,

Drill already contains logback-test.xml file in drill-common module.
Since this module is used in all other modules, there is no need to add
more logback-test.xml files.

Kind regards,
Volodymyr Vysotskyi


пт, 25 трав. 2018 о 06:05 Timothy Farkas <tf...@mapr.com> пише:

> Thanks Paul, forgot about that. I'll migrate all the tests off of
> System.out.print and onto LogFixture, I don't think its worth it to create
> a TestLogger.out since we should all be using loggers anyway. I'll also add
> a checkstyle check that will cause the build to fail of System.out.print is
> used anywhere.
>
> Thanks,
> Tim
>
> ________________________________
> From: Paul Rogers <pa...@yahoo.com.INVALID>
> Sent: Thursday, May 24, 2018 7:08:28 PM
> To: dev@drill.apache.org
> Subject: Re: [Question] Using loggers in tests
>
> LogFixture? As illustrated in ExampleTest?
>
> This fixture lets you turn on all or selected loggers for the duration of
> a single test. I used it all the time when debugging. Works great.
> It works when turning loggers on when the default is that they are off.
> For whatever reason, I could not get it to work to turn off logging that
> was enabled in the config file.
> At one point I did look into adding a custom debug logger that works just
> like System.out, but is disabled by default. That way, conversion was just
> a matter of replacing System.out with TestLogger.out which can be done via
> search/replace. Not sure if I ever checked that in, but it would be trivial
> to replicate.
> Thanks,
> - Paul
>
>
>
>     On Thursday, May 24, 2018, 5:32:49 PM PDT, Timothy Farkas <
> tfarkas@mapr.com> wrote:
>
>  Hi All,
>
> I was wondering if there was a magical way to enable the Slf4j loggers for
> unit tests without adding a logback-test.xml file into src/test/resources
> for a submodule in the project? If not, would there by any issues with
> adding a default logback-test.xml file that has logging disabled by default
> to each submodule's src/test/resources directory? I'd like to do this in
> order to discourage the use of System.out.println in tests (and eventually
> prohibit it completely) by providing an easy to use out of the box
> alternative. Currently our test logs are polluted by many System.out.print
> statements and switching to using logging will allow us to have our test
> messages when we want them, and to disable them when we don't want them.
>
> Thanks,
> Tim
>

Re: [Question] Using loggers in tests

Posted by Timothy Farkas <tf...@mapr.com>.
Thanks Paul, forgot about that. I'll migrate all the tests off of System.out.print and onto LogFixture, I don't think its worth it to create a TestLogger.out since we should all be using loggers anyway. I'll also add a checkstyle check that will cause the build to fail of System.out.print is used anywhere.

Thanks,
Tim

________________________________
From: Paul Rogers <pa...@yahoo.com.INVALID>
Sent: Thursday, May 24, 2018 7:08:28 PM
To: dev@drill.apache.org
Subject: Re: [Question] Using loggers in tests

LogFixture? As illustrated in ExampleTest?

This fixture lets you turn on all or selected loggers for the duration of a single test. I used it all the time when debugging. Works great.
It works when turning loggers on when the default is that they are off. For whatever reason, I could not get it to work to turn off logging that was enabled in the config file.
At one point I did look into adding a custom debug logger that works just like System.out, but is disabled by default. That way, conversion was just a matter of replacing System.out with TestLogger.out which can be done via search/replace. Not sure if I ever checked that in, but it would be trivial to replicate.
Thanks,
- Paul



    On Thursday, May 24, 2018, 5:32:49 PM PDT, Timothy Farkas <tf...@mapr.com> wrote:

 Hi All,

I was wondering if there was a magical way to enable the Slf4j loggers for unit tests without adding a logback-test.xml file into src/test/resources for a submodule in the project? If not, would there by any issues with adding a default logback-test.xml file that has logging disabled by default to each submodule's src/test/resources directory? I'd like to do this in order to discourage the use of System.out.println in tests (and eventually prohibit it completely) by providing an easy to use out of the box alternative. Currently our test logs are polluted by many System.out.print statements and switching to using logging will allow us to have our test messages when we want them, and to disable them when we don't want them.

Thanks,
Tim

Re: [Question] Using loggers in tests

Posted by Paul Rogers <pa...@yahoo.com.INVALID>.
LogFixture? As illustrated in ExampleTest?

This fixture lets you turn on all or selected loggers for the duration of a single test. I used it all the time when debugging. Works great.
It works when turning loggers on when the default is that they are off. For whatever reason, I could not get it to work to turn off logging that was enabled in the config file.
At one point I did look into adding a custom debug logger that works just like System.out, but is disabled by default. That way, conversion was just a matter of replacing System.out with TestLogger.out which can be done via search/replace. Not sure if I ever checked that in, but it would be trivial to replicate.
Thanks,
- Paul

 

    On Thursday, May 24, 2018, 5:32:49 PM PDT, Timothy Farkas <tf...@mapr.com> wrote:  
 
 Hi All,

I was wondering if there was a magical way to enable the Slf4j loggers for unit tests without adding a logback-test.xml file into src/test/resources for a submodule in the project? If not, would there by any issues with adding a default logback-test.xml file that has logging disabled by default to each submodule's src/test/resources directory? I'd like to do this in order to discourage the use of System.out.println in tests (and eventually prohibit it completely) by providing an easy to use out of the box alternative. Currently our test logs are polluted by many System.out.print statements and switching to using logging will allow us to have our test messages when we want them, and to disable them when we don't want them.

Thanks,
Tim