小编Jes*_*per的帖子

将日期添加到logback.xml

曾尝试搜索它,但我一直在获取...IS_UNDEFINED文件名。我只想将当前日期附加到日志文件中。logback.xml文件的任何简单示例?

这是我最近的尝试:

<Properties>
  <property name="filePattern">log_${date:yyyy-MM-dd}.log</property>
</Properties>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
  <file>${application.home:-.}/logs/${filePattern}</file>
  <encoder>
    <pattern>%date [%level] from %logger in %thread - %message%n%xException</pattern>
  </encoder>
</appender>
Run Code Online (Sandbox Code Playgroud)

xml slf4j

5
推荐指数
2
解决办法
3677
查看次数

尝试设置 PropertiesConfiguration 时出现 NoClassDefFoundError

我正在尝试设置 aFileBasedConfigurationBuilder以便我可以使用 aPropertiesConfiguration但我得到了NoClassDefFoundError. 这是我的代码

public class Config {
  private static Properties properties;
  private static PropertiesConfiguration config;

  public static void setUp(String path) throws ConfigurationException, IOException {
    if (config == null) {
      FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
          new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class)
          .configure(new Parameters().properties()
              .setFileName("myConfig.properties")
              .setThrowExceptionOnMissing(true)
              .setListDelimiterHandler(new DefaultListDelimiterHandler(','))
              .setIncludesAllowed(false));

      config = builder.getConfiguration();

      File file = new File(path);
      FileReader reader = new FileReader(file);
      config.read(reader);
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

和堆栈跟踪:

java.lang.NoClassDefFoundError: org/apache/commons/beanutils/BeanIntrospector
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.sun.proxy.$Proxy38.<clinit>(Unknown Source)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) …
Run Code Online (Sandbox Code Playgroud)

java noclassdeffounderror

1
推荐指数
1
解决办法
3142
查看次数

标签 统计

java ×1

noclassdeffounderror ×1

slf4j ×1

xml ×1