intellij idea ultimate jakarta ee logging doenst work

已回答

Hello,

im using intellij idea ultimate version. Im trying to log in doGet and in the scheduler but the logging is not going to be saved in the glassfish.log.

Im using Version Build #IU-241.18034.62, built on June 20, 2024

Im using Glassfish Version 7.0.15

Here is the code im working with:

https://github.com/hendrik-weiler/testqueries-example

I get two tabs in the services section. Server and Glassfish.log but the logging will not be output in either of them. I have tried setting in the configuration of glassfish: show console when a message is printed into outputstream but it didnt work.

The logging gets executed when i tested it in debug mode.

What am i missing that the logging doenst show up?

0

Hello,

Does it work if you deploy directly to Glassfish? Did you change domain configuration to enable slf4j logging?

0

I tried to deploy it directly to glassfish but the only log in glassfish7/glassfish/domains/domain1/logs/server.log was:

[2024-07-30T16:05:23.500908+02:00] [GF 7.0.15] [INFO] [] [jakarta.enterprise.system.core] [tid: _ThreadID=215 _ThreadName=admin-listener(6)] [levelValue: 800] [[
 testqueries-1 was successfully deployed in 382 milliseconds.]]

The interval component didnt log in the server.log with slf4j. 

I didnt change any configuration for slf4j but the System.out.println dont get printed out in the server or glassfish log tab.

0

I have resolved the issue. It had to be configured in /glassfish7/glassfish/domains/domain1/config/logging.properties.

In the properties im using this:

handlers=\

org.glassfish.main.jul.handler.SimpleLogHandler,\

org.glassfish.main.jul.handler.GlassFishLogHandler,\

org.glassfish.main.jul.handler.SyslogHandler,java.util.logging.ConsoleHandler, java.util.logging.FileHandler

… end of file …

# ConsoleHandler configuration

java.util.logging.ConsoleHandler.level=ALL

java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter


 

# FileHandler configuration

java.util.logging.FileHandler.level=ALL

java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter

java.util.logging.FileHandler.pattern=%h/glassfish/domains/domain1/logs/server.log

java.util.logging.FileHandler.limit=50000

java.util.logging.FileHandler.count=1

java.util.logging.FileHandler.append=true


 

# Root logger level

.level=INFO

In the code im using  the standard logger:

import java.util.logging.Logger;

@Startup
@Singleton
public class ScheduleTimerBean {

    private final static Logger logger = Logger.getLogger(ScheduleTimerBean.class.getName());

    @Schedule(hour = "*", minute = "*", second = "*/5", info = "Every 5 seconds timer")
    public void automaticallyScheduled(Timer timer) {
        logger.info("Timer event: " + timer.getInfo());
    }
}

0

Thanks for information!

Nice to hear that it works fine now.

0

请先登录再写评论。