WIldfly 10 +登录 [英] WIldfly 10 + logback

查看:74
本文介绍了WIldfly 10 +登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了几天的时间来尝试在我的wildfly 10项目中设置logback.

I spent last few days for trying to set up logback with my wildfly 10 project.

我的目标是:

  1. 服务器日志应由wildfly logger创建.
  2. 我的EAR日志应该通过重新登录来创建.
  3. 将登录和Wildfly记录器日志记录到控制台.

我的项目框架是由maven生成的,如下所示:

My project skeleton is generated by maven and is as follow:

  • 项目名称
  • projectname-ear
  • projectname-ejb
  • projectname-parent
  • 项目名网站

我尝试将logback.xml添加到Web和ejb项目中的资源-它不起作用.我是Wildfly的新手,不确定自己是否做对了.

I try to add logback.xml to resources in web and ejb project - it's not working. I'm new in wildfly and not sure if I am doing it right.

我试图根据

什么都没发生.然后我喜欢了另一个:

Nothing happen. Then I fond another one:

<jboss-deployment-structure>
  <deployment>
     <!-- exclude-subsystem prevents a subsystems deployment unit processors running on a deployment -->
     <!-- which gives basically the same effect as removing the subsystem, but it only affects single deployment -->
     <exclude-subsystems>
        <subsystem name="logging" />
    </exclude-subsystems>
  </deployment>
</jboss-deployment-structure>

什么都没有发生.我现在做错什么了吗?

Nothing happen at all. Am I doing something wrong in this moment?

然后我在本教程中找到了替换wildfly logger的解决方案.>.

Then I found solution with replacing wildfly logger in this tutorial.

它有效,但是有一个巨大的缺点.日志翻倍 - 看起来 logback 和 wildfly logger 一次记录到控制台.在logger.properties中禁用wildfly logger无效.

It works but there is one huge disadvantage. Logs are doubled - it looks that logback and wildfly logger logging at once to console. Disabling wildfly logger in logger.properties doesn't work.

我不知道我花了很多时间来实现记录器.Logback + android 是一块蛋糕的和平.感谢所有有关此问题的好的建议和经验.

I had no idea that I spent so much time for implementing logger. Logback + android was a peace of cake. I appreciate all good advices and experience with this problem.

推荐答案

使用 jboss-deployment-structure.xml 所具有的功能将起作用,但是由于您使用的是EAR,因此您会每个 sub-部署.我将不包括日志记录子系统,因为您不需要子系统的任何部分来处理部署.

What you have with the jboss-deployment-structure.xml will work, but because you're using an EAR you'll need to do the same exclusions for each sub-deployment. I would just exclude the logging subsystem since you won't need any part of the subsystem processing your deployment.

将jboss-deployment-structure.xml添加到您的EAR项目到目录 projectname-ear/src/main/application/META-INF 中.

Add jboss-deployment-structure.xml to Your EAR project into directory projectname-ear/src/main/application/META-INF.

另一种选择是将 add-logging-api-dependenciesuse-deployment-logging-config 更改为 false.使用此选项要注意的一点是,它将停止将日志记录依赖项添加到所有部署中.如果您只有一个部署或所有部署都使用我们 logback 作为日志管理器,那么这将是最简单的选择.

Another option would be to change the add-logging-api-dependencies and the use-deployment-logging-config to false. The thing to note with this option is it will stop the logging dependencies from getting added to ALL deployments. If you've only got the one deployment or all your deployments us logback for the log manager, then this would be the easiest option.

更新:示例 jboss-deployment-structure.xml

Update: Example jboss-deployment-structure.xml

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <deployment>
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
    </deployment>
    <sub-deployment name="projectname-web.war">
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
    </sub-deployment>
    <sub-deployment name="projectname-ejb.jar">
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
    </sub-deployment>
</jboss-deployment-structure>

要删除重复的日志,请检查帖子.

To remove duplicated logs check this post.

这篇关于WIldfly 10 +登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆