hsqldb内部事件日志配置

发布于 2024-10-04 01:06:24 字数 531 浏览 0 评论 0原文

如何在 hsqldb 中配置内部事件监控?当我运行 Java 应用程序时,我收到以下警告:

log4j:WARN No appenders could be found for logger (HSQLDB2C7984E18B.org.hsqldb.persist.Logger).
log4j:WARN Please initialize the log4j system properly.

文档 告诉我 log4j 不是唯一的选择,但它没有告诉我如何配置我的应用程序。谁能指点我这个文档?请记住,我不想想对 hsqldb 使用 log4j。

值得一提的是,我引用的第 3 方 jar 需要 log4j。 hsqldb 是否会自动检测 log4j 是否存在,然后尝试使用它?或者我是否遗漏了有关日志记录工作原理的一些基本知识?

How do I configure internal event monitoring in hsqldb? When I run my Java application, I get the following warnings:

log4j:WARN No appenders could be found for logger (HSQLDB2C7984E18B.org.hsqldb.persist.Logger).
log4j:WARN Please initialize the log4j system properly.

The documentation tells me log4j is not the only option, but it doesn't tell me how to configure my application. Can anyone point me to this documentation? Remember, I don't want to use log4j for hsqldb.

It bears mentioning that a 3rd-party jar I'm referencing requires log4j. Does hsqldb automatically detect that log4j is present and then attempt to use it? Or am I missing something fundamental about how logging works?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暖伴 2024-10-11 01:06:24

查看此链接。它说

如果在类路径中找到 Log4j,则日志记录工具将移交给 Log4j,否则将移交给 java.util.logging。

Check out this link. It says

The logging facility hands off to Log4j if Log4j is found in the classpath, and otherwise will hand off to java.util.logging.

窗影残 2024-10-11 01:06:24

该消息所指示的结果是,由于未找到附加程序,因此不会发生 HSQLDB 日志记录。

如果您希望抑制该消息,请在 log4j.properties 文件中添加如下一行:

log4j.logger.HSQLDB2C7984E18B.org.hsqldb.persist.Logger=FATAL

这将仅记录 FATAL 事件,这在正常操作中不会发生。

您还声明您不想对 HSQLDB 使用 log4j。可以使用 log4j 的软件组件将日志记录配置(包括级别和记录位置等)留给 log4j 属性设置,您可以对其进行编辑和配置。

在这种情况下,记录器名称基于最初自动生成的“唯一”数据库名称,但您可以在 HSQLDB 中更改该名称。

The consequence of what the message indicates is that no logging for HSQLDB will take place because no appenders were found.

If you wish to suppress the message, add a line like the one below to the log4j.properties file:

log4j.logger.HSQLDB2C7984E18B.org.hsqldb.persist.Logger=FATAL

This will log only FATAL events, which wouldn't happen in normal operation.

You also state that you don't want to use log4j for HSQLDB. Software components that can use log4j leave the logging configuration (including level and where to log, etc.) to the log4j properties settings, which you can edit and configure.

In this case, the logger name is based on the "unique" database name which is initially autogenerated, but which you can change in HSQLDB.

冰葑 2024-10-11 01:06:24

因为正如 YWE 指出的那样,如果在类路径中找到了 hsqldb,则默认情况下使用 log4j,因此我需要弄清楚如何覆盖在第 3 方库中找到的 log4j.properties。我设法执行以下操作:

  1. 将现有的 log4j.properties 复制到我的项目中,并在开头添加以下行:

    log4j.rootLogger=警告,控制台
    
  2. 添加以下 VM 参数:

    -Dlog4j.log4j.defaultInitOverride=true
    -Dlog4j.configuration=C:/full/path/to/my/log4j.properties
    
  3. 确保这行代码在任何人(例如 hsqldb)尝试使用 log4j 之前运行:

    org.apache.log4j.PropertyConfigurator.configure("log4j.properties");
    

Because as YWE noted hsqldb uses log4j by default if it is found in the classpath, I needed to figure out how to override the log4j.properties found in the 3rd-party library. This I managed to do as follows:

  1. Copy the existing log4j.properties to my project, and add the following line at the beginning:

    log4j.rootLogger=WARN, CONSOLE
    
  2. Add the following VM Arguments:

    -Dlog4j.log4j.defaultInitOverride=true
    -Dlog4j.configuration=C:/full/path/to/my/log4j.properties
    
  3. Make sure this line of code runs before anyone (e.g. hsqldb) attempts to use log4j:

    org.apache.log4j.PropertyConfigurator.configure("log4j.properties");
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文