Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildfly and logback with blank lines

I'm trying to use Logback with Wildfire 9. For that, I added a jboss-deployment-structure.xml file in my WEB-INF folder with this content (I excluded also Hibernate to be sure to not pull jboss-logging):

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
        <exclusions>
            <module name="org.hibernate" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

It's working fine except I have blank lines between each log:

14:25:25,249 INFO  [org.jboss.as.jpa] (MSC service thread 1-8) WFLYJPA0002: Read persistence.xml for portalPU
14:25:25,253 INFO  [org.jboss.as.jpa] (MSC service thread 1-8) WFLYJPA0002: Read persistence.xml for emptyPU
14:25:25,631 INFO  [stdout] (MSC service thread 1-1) 14:25:25,556 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]

14:25:25,631 INFO  [stdout] (MSC service thread 1-1) 14:25:25,557 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]

and:

14:26:49,827 INFO  [stdout] (default task-2) 2016-05-03 14:26:49 [default task-2] DEBUG f.s.q.p.web.filters.InstallFilter -Users found: 1

14:26:50,676 INFO  [stdout] (default task-3) 2016-05-03 14:26:50 [default task-3] DEBUG f.s.q.p.web.filters.InstallFilter -Users found: 1

14:26:50,716 INFO  [stdout] (default task-4) 2016-05-03 14:26:50 [default task-4] DEBUG f.s.q.p.web.filters.InstallFilter -Users found: 1

14:26:50,760 INFO  [stdout] (default task-5) 2016-05-03 14:26:50 [default task-5] DEBUG f.s.q.p.web.filters.InstallFilter -Users found: 1

14:26:50,779 INFO  [stdout] (default task-6) 2016-05-03 14:26:50 [default task-6] DEBUG f.s.q.p.web.filters.InstallFilter -Users found: 1

14:26:51,162 INFO  [stdout] (default task-8) 2016-05-03 14:26:51 [default task-8] DEBUG f.s.q.p.web.filters.InstallFilter -Users found: 1

14:26:51,180 INFO  [stdout] (default task-7) 2016-05-03 14:26:51 [default task-7] DEBUG f.s.q.p.web.filters.InstallFilter -Users found: 1

In my logback.xml, I'm using this pattern for the console:

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern><![CDATA[%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %logger{36} -%msg%n]]></Pattern>
    </layout>
</appender>

And in the logging.properties file of Wildfly, I have this:

formatter.COLOR-PATTERN=org.jboss.logmanager.formatters.PatternFormatter
formatter.COLOR-PATTERN.properties=pattern
formatter.COLOR-PATTERN.pattern=%K{level}%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%e%n

I think the problem is comming from the %n for the ConsoleAppender and the PatternFormatter. If I'm trying to remove the %n for ConsoleAppender, it's like if I don't have flushes anymore: I can't see the logs. If I remove the %n for PatternFormatter, I don't have the blank lines but Wildfly's logs don't have linefeed anymore.

How to have something clean without blank lines ?

like image 763
stefv Avatar asked May 03 '16 12:05

stefv


1 Answers

I have removed %n in standalone.xml and now the log in Eclipse console is fine

<formatter name="COLOR-PATTERN">
    <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e"/>
</formatter>
like image 71
Igor Vuković Avatar answered Sep 26 '22 14:09

Igor Vuković