Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetty logging initialization does not wait for :init #190

Open
kumarshantanu opened this issue Jul 21, 2017 · 11 comments
Open

Jetty logging initialization does not wait for :init #190

kumarshantanu opened this issue Jul 21, 2017 · 11 comments

Comments

@kumarshantanu
Copy link

I initialize logging in a custom way in the :init function, which has no effect because Jetty already initializes SLF4j/Logback logging ahead of :init. lein-ring should not directly refer to the Jetty classes (to avoid logging initialization) until the :init function is executed.

@kumarshantanu
Copy link
Author

Currently, I'm working around this issue by creating a file test/jetty-logging.properties with the following content:

org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog

This forces Jetty to log to STDERR, without initializing any other logging.

@MichaelBlume
Copy link
Collaborator

I think it should absolutely be possible to ensure that no side effects occur before the user's init is run. @weavejester is there any reason I'm missing to prefer the current behavior?

@weavejester
Copy link
Owner

None that I can think of.

@MichaelBlume
Copy link
Collaborator

Actually, @kumarshantanu can you give me some more help replicating this? How are you running your server? Are you deploying a war or a jar?

If you're building a war, jetty is fundamentally in charge and running our code when it wants to, so we may not be able to avoid the init that's giving you trouble (we may be able to, I'm not sure, would need to replicate first)

@kumarshantanu
Copy link
Author

I deploy a simple uberjar, where the main class

  1. reads config file
  2. uses some of the config to initialize SLF4j/Logback
  3. loads rest of the application that logs via SLF4j

in that order. My Logback config is complex and parameterized, however, let's take a simple example - I want the value of immediateFlush to be true in dev (using lein-ring) and false in prod (using http-kit), so I use a variable there (as in <immediateFlush>${immediate.flush}</immediateFlush>) that I must configure in lein-ring's :init function.

I will be happy to test any unreleased changes toward fixing this issue.

@MichaelBlume
Copy link
Collaborator

MichaelBlume commented Aug 4, 2017 via email

@MichaelBlume
Copy link
Collaborator

MichaelBlume commented Aug 4, 2017 via email

@kumarshantanu
Copy link
Author

kumarshantanu commented Aug 4, 2017

@MichaelBlume I use lein-ring only during development. For production, I create the uberjar using lein uberjar with my own AOT main class/namespace.

@MichaelBlume
Copy link
Collaborator

Ah, and the problem you are having is at development time?

@kumarshantanu
Copy link
Author

Yes, that's right. I see the problem only at development time.

@MichaelBlume
Copy link
Collaborator

Ok, so I think with a bit of redirection I could ensure that init runs before any libraries are loaded. My concern is that this behavior will probably be different from what we see if a project is deployed to a jetty server with lein war, say. In general I'd prefer for the same project to behave the same way if run with various lein-ring commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants