java - Any tool to annotate a method so that method do not produce logs -
i have junit tests. in tests test cases goes exception blocks in testing method. , logs errors, ends in junit test results. can slf4j configuration , omit whole class logging. wish can annotate test method , ever code runs not produce logs.
(a) can use 2 loggers, default class , 1 method-specific in method:
private static final logger log = loggerfactory.getlogger(yourservice.class); private static final logger customlog = loggerfactory.getlogger(yourservice.class.getcanonicalname() + "#yourmethod");
(b) or can adjust logging system in test setup/teardown:
@setup public void setup() { logger log = loggerfactory.getlogger(yourservice.class); ((loggerimlpementationclass) log).setloglevel(...); } // same, reset, in tear down method.
however in case required change logger dependency scope runtime test (in maven terms).
Comments
Post a Comment