NutzCN Logo
问答 Nutz boot Log Debug 如何输出到指定的文件
发布于 2434天前 作者 wx_fogihiqrpafhr974b120 1736 次浏览 复制 上一个帖子 下一个帖子
标签:

log4j.properties配置如下:
log4j.rootLogger=debug,Console,D
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%-5p] %d{HH:mm:ss.SSS} %l - %m%n

输出DEBUG 级别以上的日志到=./logs/debug.log

log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = D:/logs/log.log
log4j.appender.D.Append = true
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n

可是,运行程序后,DEBUG的信息只在控制台中显示,而不在D:/logs/log.log中输出。
log4j-1.2.17.jar也加入了,还是不行。

5 回复

slf4j-over-log4j12 加了没

另外,你写的是相对路径,启动的时候在d盘根目录?

[INFO] --- maven-shade-plugin:3.0.0:shade (default) @ appserver ---
[INFO] Including org.nutz:nutzboot-starter-swagger:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including io.swagger:swagger-servlet:jar:1.5.18 in the shaded jar.
[INFO] Including io.swagger:swagger-core:jar:1.5.18 in the shaded jar.
[INFO] Including org.apache.commons:commons-lang3:jar:3.2.1 in the shaded jar.
[INFO] Including com.fasterxml.jackson.core:jackson-annotations:jar:2.9.3 in the shaded jar.
[INFO] Including com.fasterxml.jackson.core:jackson-databind:jar:2.9.3 in the shaded jar.
[INFO] Including com.fasterxml.jackson.core:jackson-core:jar:2.9.3 in the shaded jar.
[INFO] Including com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.9.3 in the shaded jar.
[INFO] Including org.yaml:snakeyaml:jar:1.18 in the shaded jar.
[INFO] Including io.swagger:swagger-models:jar:1.5.18 in the shaded jar.
[INFO] Including io.swagger:swagger-annotations:jar:1.5.18 in the shaded jar.
[INFO] Including javax.validation:validation-api:jar:1.1.0.Final in the shaded jar.
[INFO] Including org.reflections:reflections:jar:0.9.11 in the shaded jar.
[INFO] Including org.javassist:javassist:jar:3.22.0-GA in the shaded jar.
[INFO] Including com.google.guava:guava:jar:20.0 in the shaded jar.
[INFO] Including org.nutz:nutzboot-core:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including javax.servlet:javax.servlet-api:jar:3.1.0 in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-jetty:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-servlets:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-continuation:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-http:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-util:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-io:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-webapp:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-xml:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-servlet:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-security:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-server:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty.websocket:websocket-server:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty.websocket:websocket-common:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty.websocket:websocket-api:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty.websocket:websocket-client:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-client:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty.websocket:websocket-servlet:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty.websocket:javax-websocket-server-impl:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-annotations:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including org.eclipse.jetty:jetty-plus:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including javax.annotation:javax.annotation-api:jar:1.2 in the shaded jar.
[INFO] Including org.ow2.asm:asm:jar:6.0 in the shaded jar.
[INFO] Including org.ow2.asm:asm-commons:jar:6.0 in the shaded jar.
[INFO] Including org.ow2.asm:asm-tree:jar:6.0 in the shaded jar.
[INFO] Including org.eclipse.jetty.websocket:javax-websocket-client-impl:jar:9.4.9.v20180320 in the shaded jar.
[INFO] Including javax.websocket:javax.websocket-client-api:jar:1.0 in the shaded jar.
[INFO] Including javax.websocket:javax.websocket-api:jar:1.0 in the shaded jar.
[INFO] Including org.slf4j:jul-to-slf4j:jar:1.7.25 in the shaded jar.
[INFO] Including org.nutz:nutz-plugins-websocket:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-nutz-mvc:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-nutz-dao:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz-plugins-daocache:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-jdbc:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including com.alibaba:druid:jar:1.1.9 in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-redis:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz-integration-jedis:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including redis.clients:jedis:jar:2.9.0 in the shaded jar.
[INFO] Including org.apache.commons:commons-pool2:jar:2.4.2 in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-quartz:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz-integration-quartz:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including org.quartz-scheduler:quartz:jar:2.3.0 in the shaded jar.
[INFO] Including com.mchange:mchange-commons-java:jar:0.2.11 in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-weixin:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutzwx:jar:1.r.65 in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-shiro:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz-integration-shiro:jar:1.r.66-SNAPSHOT in the shaded jar.

[INFO] Including org.slf4j:jcl-over-slf4j:jar:1.7.25 in the shaded jar.

[INFO] Including org.apache.shiro:shiro-web:jar:1.3.2 in the shaded jar.
[INFO] Including org.apache.shiro:shiro-core:jar:1.3.2 in the shaded jar.
[INFO] Including commons-beanutils:commons-beanutils:jar:1.8.3 in the shaded jar.
[INFO] Including org.apache.shiro:shiro-ehcache:jar:1.3.2 in the shaded jar.
[INFO] Including net.sf.ehcache:ehcache:jar:2.10.4 in the shaded jar.
[INFO] Including org.nutz:nutz-plugins-cache:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-beetl:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including com.ibeetl:beetl:jar:2.8.0 in the shaded jar.
[INFO] Including org.antlr:antlr4-runtime:jar:4.5 in the shaded jar.
[INFO] Including org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1 in the shaded jar.
[INFO] Including com.alibaba:fastjson:jar:1.2.26 in the shaded jar.
[INFO] Including io.netty:netty:jar:3.7.0.Final in the shaded jar.

[INFO] Including org.slf4j:slf4j-api:jar:1.7.21 in the shaded jar.

[INFO] Including org.slf4j:slf4j-log4j12:jar:1.7.21 in the shaded jar.

[INFO] Including log4j:log4j:jar:1.2.17 in the shaded jar.

[INFO] Including com.h2database:h2:jar:1.4.196 in the shaded jar.
都package,打在JAR包里了。

找到问题了:我为了打成jar后能灵活改动点配置,所以没把配置文件打在JAR报里,在pom.xml里加了下面的配置

结果悲剧了。。。
感谢wendal 给我的提示。

发日志用 插入日志 按钮,为啥那么明显都看不到呢。。。

添加回复
请先登陆
回到顶部