logback.xml 的 XML 架构或 DTD?

发布于 2024-11-02 15:15:47 字数 127 浏览 6 评论 0原文

我在网上看到过一些关于为 logback.xml 文件提供 XML 模式或 DTD 以便在 IDEA 或 Eclipse 等 IDE 中至少具有非常基本的验证和自动完成功能会有多棒的讨论,但我从未见过任何解决方案。

你有吗?

I've seen several discussions on the net about how great it would be to have an XML schema or DTD for logback.xml file to have at least the very basic validation and auto-completion in IDEs like IDEA or Eclipse, but I never saw any solution.

Did you?

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

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

发布评论

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

评论(7

奈何桥上唱咆哮 2024-11-09 15:15:47

只是为了摆脱 Eclipse 中烦人的警告,在 之后添加 >。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>

要在修复后消除感叹号图标,您可能需要通过右键单击文件并选择验证来再次触发验证。

Just to get rid of the annoying warning in Eclipse add <!DOCTYPE xml> after <?xml version="1.0" encoding="UTF-8"?>.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>

To get rid of the exclamation point icon after you fix it, you might need to trigger the validation again by right-clicking the file and choosing Validate.

踏月而来 2024-11-09 15:15:47

截至 2011 年 6 月,官方文档指出

正如应该清楚的那样,logback 配置文件的语法非常灵活。因此,不可能使用 DTD 文件或 XML 模式指定允许的语法。

关于该主题有一个简短的帖子,但没有似乎哪儿也去不了。

As of June 2011, the official documentation states

As shall become clear, the syntax of logback configuration files is extremely flexible. As such, it is not possible specify the allowed syntax with a DTD file or an XML Schema.

There was a brief thread on the topic, but didn't seem to go anywhere.

神魇的王 2024-11-09 15:15:47

根据文档官方不支持它,但是有一个独立的项目可以支持提供 Logback 的 Schema

但是,由于 Logback 配置的极大灵活性,Schema 无法支持所有可能的配置选项。

It is not supported officially according to the documentation, but there is an independent project to provide Schema for Logback

However, due to extreme flexibility of the Logback configuration, Schema cannot support all possible configuration options.

月下客 2024-11-09 15:15:47

Sergey 提到的独立项目满足了我的大部分需求。

但是,缺少一些元素,我将它们添加到 https://github.com/nkatsar 上我自己的分叉上/logback-XSD。希望它们能够合并到主项目中。

The independent project mentioned by Sergey covered most of my requirements.

However, some elements were missing, I added them on my own fork on on https://github.com/nkatsar/logback-XSD. Hope they will get merged in the main project.

趁微风不噪 2024-11-09 15:15:47
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.padual.com/java/logback.xsd">

来自 GitHub“logback 的 XML 模式定义”
https://github.com/nkatsar/logback-XSD

<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.padual.com/java/logback.xsd">

from GitHub "An XML Schema Definition for logback"
https://github.com/nkatsar/logback-XSD

摇划花蜜的午后 2024-11-09 15:15:47

感谢 https://github.com/enricopulatzo/logback-XSD

这将允许 Eclipse自动完成并验证 xml 是否未使用插件或其他扩展机制:

<?xml version="1.0" encoding="UTF-8"?>
<configuration
    xmlns="http://ch.qos.logback/xml/ns/logback"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://ch.qos.logback/xml/ns/logback 
https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd
">

Thanks to https://github.com/enricopulatzo/logback-XSD

This will allow eclipse to autocomplete and validate if xml is not using plugins or other extensions mechanisms:

<?xml version="1.0" encoding="UTF-8"?>
<configuration
    xmlns="http://ch.qos.logback/xml/ns/logback"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://ch.qos.logback/xml/ns/logback 
https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd
">
长亭外,古道边 2024-11-09 15:15:47
<?xml version="1.0" encoding="UTF-8"?>
<configuration
    xmlns="http://ch.qos.logback/xml/ns/logback"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://ch.qos.logback/xml/ns/logback 
https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd
">

使用这条线。它会自动从远程下载。我们不需要下载文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration
    xmlns="http://ch.qos.logback/xml/ns/logback"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://ch.qos.logback/xml/ns/logback 
https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd
">

use this lines . it download automatically from remote. we need not to downlaod the file

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