0

Netbeans does not display log4j2 messages correct in the Glassfish Server Output window. But if I look at the glassfish server log, everthing is displayed correctly.

In my controller I have the following

System.out.println("This is a debug messages!\n\tWith new line and tab.");
LOG.debug("This is a debug messages!\n\tWith new line and tab.");

When I run my app I get the following in my output window in Netbeans

 This is a debug messages!
    With new line and tab.|#]  <-- System.out.println
    With new line and tab.     <-- LOG.debug
|#]

But looking in the server log everything is looking fine

[2023-03-30T17:17:02.256+0200] [glassfish 6.2] [INFO] [] [] [tid: _ThreadID=187 _ThreadName=Thread-7] [timeMillis: 1680189422256] [levelValue: 800] [[
  This is a debug messages!
    With new line and tab.]]

[2023-03-30T17:17:02.483+0200] [glassfish 6.2] [INFO] [] [] [tid: _ThreadID=187 _ThreadName=Thread-7] [timeMillis: 1680189422483] [levelValue: 800] [[
  17:17:02.393 [RoomController] DEBUG - This is a debug messages!
    With new line and tab.
]]

log4j2.xml in WEB-INF

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%c{1}] %-5level - %msg%n"/>
        </Console>

    </Appenders>
    <Loggers>
        <Root level="DEBUG">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>

I am using

Glassfish 6.2.5
NetBeans 16
Log4j2 2.20.0

I could not find any setting to tweak. Is there another way in netbeans to display glassfish log messages?


Other questions found on same topic:

amittel
  • 1
  • 2
  • I think it has something to do with [Cropped console output with GlassFish + slf4j + logback](https://issues.apache.org/jira/browse/NETBEANS-4455) or [log4j messages missing in GlassFish server log](https://issues.apache.org/jira/browse/NETBEANS-3326). Try to change your pattern and insert a newline at the start of the pattern, maybe it helps. – Filou Aug 25 '23 at 07:41

0 Answers0