如何在级别上记录我的应用程序代码DEBUG
,但将某些库依赖项限制在WARN
级别上?具体来说,我很难控制c3p0和Amazon SDK。谁能告诉我为什么我的设置不起作用?因为我不明白为什么我仍然在日志文件中看到 AWS 极其冗长的 DEBUG 日志记录。
下面我已经包含了我的logback.xml
和我的相关摘录project.clj
。
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>
${catalina.home}/logs/MY_APP.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<!-- the "%i" is because of the SizeAndTimeBasedFNATP -->
<!-- keep 5 days' worth of history -->
<maxHistory>5</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 20MB -->
<maxFileSize>20MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="FILE" />
</root>
<!-- The amazon sdk -->
<logger name="com.amazonaws" level="WARN" additivity="false">
<appender-ref ref="FILE" />
</logger>
<!-- The c3p0 connection pooling library that Korma uses. -->
<logger name="com.mchange" level="WARN" additivity="false">
<appender-ref ref="FILE" />
</logger>
</configuration>
(defproject …
:dependencies [[org.clojure/clojure "1.4.0"]
[org.slf4j/slf4j-api "1.7.2"]
;; Amazon Web Services' S3
[clj-aws-s3 "0.3.2"]
[org.slf4j/jcl-over-slf4j "1.7.2"] ; for underlying AWS SDK
;; SQL abstraction
[korma "0.3.0-beta11"]
[org.slf4j/log4j-over-slf4j "1.7.2"] ; for c3p0 (package begins with "com.mchange"), which is a dependency of Korma
;; HTTP abstraction
[ring/ring-core "1.1.6"]
;; routing DSL
[compojure "1.1.3"]
;; for determining MIME types of sent files
[com.novemberain/pantomime "1.4.0"]
;; Take a wild guess.
[org.clojure/tools.logging "0.2.4"]
;; Finally, the actual logging implementation
[ch.qos.logback/logback-classic "1.0.7"]
;; Environmental variables that integrate with profiles
[environ "0.3.0"]]
:exclusions [commons-logging
log4j]
…