Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty http2 client request hangs indefinitely

>oggers are hierarchical.

When you declare a logger for ...

final static Logger logger =  Logger.getLogger(com.acme.project.MyClass.class.getName());

You are asking for a logger on ...
  • / (root)
    • com
      • acme
        • project
          • MyClass <-- this leaf
          • MyOtherClass
          • utils
            • UtilityLib
        • common
          • CoreBehaviors

The logging configuration you give is for that specific logger and all children.

So if you obtain a logger at say "com.acme" via Logger.getLogger("com.acme")
and then setup an appender on that logger then all events that belong within "com.acme.*" get that configuration.
Such as from com.acme.common.CoreBehaviors, and com.acme.project.MyOtherClass, and com.acme.project.utils.UtilityLib, etc...
But not from org.eclipse.jetty.*

You can put the logging configuration anywhere in this hierarchy that best suits you.

log4j is quite capable, but doesn't have some advanced features that other slf4j implementation offer.
Such as SiftingAppenders (which will pick details from the logging event, its NDC, and its MDC to route logging events).
Or Discriminators that allow you to associate Appenders to details in the logging event (or its NDC, or its MDC).

Thanks very much for the explanation Joakim, now I understood how it works :)

On Thu, Sep 26, 2019 at 11:53 PM Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
Loggers are hierarchical.

When you declare a logger for ...

final static Logger logger =  Logger.getLogger(com.acme.project.MyClass.class.getName());

You are asking for a logger on ...
  • / (root)
    • com
      • acme
        • project
          • MyClass <-- this leaf
          • MyOtherClass
          • utils
            • UtilityLib
        • common
          • CoreBehaviors

The logging configuration you give is for that specific logger and all children.

So if you obtain a logger at say "com.acme" via Logger.getLogger("com.acme")
and then setup an appender on that logger then all events that belong within "com.acme.*" get that configuration.
Such as from com.acme.common.CoreBehaviors, and com.acme.project.MyOtherClass, and com.acme.project.utils.UtilityLib, etc...
But not from org.eclipse.jetty.*

You can put the logging configuration anywhere in this hierarchy that best suits you.

log4j is quite capable, but doesn't have some advanced features that other slf4j implementation offer.
Such as SiftingAppenders (which will pick details from the logging event, its NDC, and its MDC to route logging events).
Or Discriminators that allow you to associate Appenders to details in the logging event (or its NDC, or its MDC).

Joakim Erdfelt / joakim@xxxxxxxxxxx


On Thu, Sep 26, 2019 at 1:10 AM Santhosh Kumar <santhosh89j@xxxxxxxxx> wrote:
>Since it is the first request that triggers the connection opening, I
want to see the debug logs to understand why the connection
establishment failed

I m trying to get the debug logs but I face a problem where debug logs are always redirected to RootLogger (SLF4j-log4j). How to redirect the debug logs to logs file other than rootLogger. I have also raised a SO question with other details like how I tried( https://stackoverflow.com/questions/58101857/move-jetty-httpclient-debug-logs-from-rootlogger ). Kindly let us know how to handle this case.

My sample is as follows,

private final static Logger logger =  Logger.getRootLogger();

public static void main(String[] args) {
    DailyRollingFileAppender timeAppender = new DailyRollingFileAppender();
    timeAppender.setDatePattern("'.'yyyy-MM-dd-HH-mm");//write at start of every minute
    timeAppender.setName("FileLogger");
    timeAppender.setFile("/path-to-log/client.log");
    timeAppender.setLayout(new PatternLayout("%t %p %d %-5p [%c{1}] %m%n"));
    timeAppender.setThreshold(Level.ALL);
    timeAppender.setAppend(true);
    timeAppender.activateOptions();
    logger.setAdditivity(false);
    logger.addAppender(timeAppender);

    logger.debug("JDK Used-->"+System.getProperty("java.version"));
    //HttpClient code follows
    ......

and my logger files prints,

main DEBUG 2019-09-25 20:26:07,347 DEBUG [JettyJMX] JDK -->1.8.0_212
main DEBUG 2019-09-25 20:26:07,485 DEBUG [log] Logging to org.slf4j.impl.Log4jLoggerAdapter(org.eclipse.jetty.util.log) via org.eclipse.jetty.util.log.Slf4jLog
main INFO 2019-09-25 20:26:07,488 INFO  [log] Logging initialized @370ms to org.eclipse.jetty.util.log.Slf4jLog
main DEBUG 2019-09-25 20:26:07,591 DEBUG [ContainerLifeCycle] HttpClient@65e579dc{STOPPED} added 
....

But I don't want to use rootLogger as other thirdparty packages may use slf4j in my application so I want to redirect jetty debug logs to a separate file. So, instead of using RootLogger I tried using class logger like

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

which only prints,

main DEBUG 2019-09-25 20:49:03,676 DEBUG [JettyJMX] JDK -->1.8.0_212 

SLF4j Jars Used: log4j-1.2.15.jar, slf4j-api-1.7.25.jar, slf4j-log4j12-1.7.25.jar

Jetty Version Used- 9.4.19

Jdk Used: 1.8

I can get debug logs only if I use rootLogger, is there a way or configuration to redirect debug logs from RootLogger to any other loggers?

Thanks In Advance




On Mon, Sep 23, 2019 at 11:41 AM Santhosh Kumar <santhosh89j@xxxxxxxxx> wrote:
>What I see from the dump is that the requests get queued and there are
no established connections.
Since it is the first request that triggers the connection opening, I
want to see the debug logs to understand why the connection
establishment failed, and how it failed (as any failure should have
aborted the queued requests).

The remote server is always accessible(verified by browser, curl, wget or even another jetty standalone program)  when threads are hung.

>You make requests by host or by IP address (i.e. is DNS involved)?

We make requests by IP address.

I ll try to get the debug logs asap

Thanks :)





On Fri, Sep 20, 2019 at 7:54 PM Simone Bordet <sbordet@xxxxxxxxxxx> wrote:
Hi,

On Fri, Sep 20, 2019 at 2:09 PM Santhosh Kumar <santhosh89j@xxxxxxxxx> wrote:
> Enabling Debug logs in production servers are real headache, anyhow I ll try to get the logs somehow. My doubt is *first* request you mean whether its a very first request fired by the client or the first request which hangs?

What I see from the dump is that the requests get queued and there are
no established connections.
Since it is the first request that triggers the connection opening, I
want to see the debug logs to understand why the connection
establishment failed, and how it failed (as any failure should have
aborted the queued requests).
You make requests by host or by IP address (i.e. is DNS involved)?

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users


--
With Regards,
Santhosh Kumar J


--
With Regards,
Santhosh Kumar J
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users


--
With Regards,
Santhosh Kumar J

Back to the top