Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

configuration - How to configure logback for package?

Is it possible to configure logback to log at e.g. WARN or INFO level for all packages but x.y? And then separate configuration for package x.y only.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I don't know of any way you can get the "NOT" package aspect of your question, but I routinely log one package at DEBUG and all the rest at INFO and...above is it...WARN and ERROR. This is straight up-the-middle logback. My loggers are all like...

package rekdev.org.service.api;
public class DefaultConfigResource {
    // ...
    private static final Logger log = LoggerFactory.getLogger( DefaultConfigResource.class );
    // ...
}

...on a logback.xml configuration like...

  <logger name="rekdev.org.service.api" level="debug" />
  ...
  <root level="info">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="DAILY_ROLLING" />
    <appender-ref ref="SYSLOG" />
  </root>

Has the effect of most output popping out at INFO, WARN, ERROR but all the rekdev.org.service.api classes. All the classes in the rekdev.org.service.api package produce output at DEBUG, INFO, WARN, ERROR.

Or did I misunderstand your questions entirely?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...