Logback.xml配置 [英] Logback.xml configuration
问题描述
我正在尝试将粗壮啤酒配置为保存到文件中. 但是,它不会保存到文件中-您知道为什么吗? 另外-我希望日志文件名可以在logback.xml中进行配置 诸如{LOG_FILE_NAME}之类的内容将来自cmd-是否可以?
I am trying to configure the stout to save into a file. However, it is not saved to a file - do you have an idea why?. also - I want the log file name would be configurable inside the logback.xml something like {LOG_FILE_NAME} which will come from the cmd - is it possible?
这是我的logback.xml:
This is my logback.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- For assistance related to logback-translator or configuration -->
<!-- files in general, please contact the logback user mailing list -->
<!-- at http://www.qos.ch/mailman/listinfo/logback-user -->
<!-- -->
<!-- For professional support please see -->
<!-- http://www.qos.ch/shop/products/professionalSupport -->
<!-- -->
<configuration>
<appender name="defaultLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--See also http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
<File>sarit_test.log</File>
<encoder>
<pattern>%d{dd MMM yyyy HH:mm:ss.SSS} [%t] %-5p %x %F:%L - %m</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"/>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>50000KB</MaxFileSize>
</triggeringPolicy>
</appender>
<root level="INFO">
<appender-ref ref="defaultLog"/>
</root>
</configuration>
推荐答案
<File>
节点应全部使用小写字母.所以,而不是
The <File>
node should be all in lower-case letters. So, instead of
<File>sarit_test.log</File>
应该是
<file>sarit_test.log</file>
这是您犯的错误之一,请尝试解决它(也许它可以解决问题),然后在下一次,请将错误消息附加到您的问题中.
This was one of the mistakes that you have made, try to fix it (maybe it solves the issue) and next time, please append the error message to your question.
这篇关于Logback.xml配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!