pjlegato / ring.middleware.logger

Ring middleware to log each request
57 stars 24 forks source link

log4j warnings #7

Open boxxxie opened 11 years ago

boxxxie commented 11 years ago

using your examples. so i'm missing something in my package.clj or something... would be nice to have this documented (i'm new to log4j as well).

log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
kendagriff commented 11 years ago

+1 I haven't been able to get rid of it even after adding a log4j.properties file.

LiBinglin commented 10 years ago

+1 why so far I didn't find anyone who has solved it

taylorlapeyre commented 10 years ago

+1

codeitagile commented 9 years ago

I got snagged on this too:

lein ring server 8000
log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Started server on port 8000

The following worked for me: the log4j.properties file needs to be in the CLASSPATH. Try putting it in the /src/ directory. Once I did this everything worked fine.

lein ring server 8000
INFO  org.eclipse.jetty.util.log: Logging initialized @897ms
INFO  org.eclipse.jetty.server.Server: jetty-9.2.10.v20150310
INFO  org.eclipse.jetty.server.ServerConnector: Started ServerConnector@79080255{HTTP/1.1}{0.0.0.0:8000}
INFO  org.eclipse.jetty.server.Server: Started @3636ms
Started server on port 8000
INFO  onelog.core: Starting :get / for 127.0.0.1 {"cookie" "plushContainerWidth=100%25; plushMultiOps=1; plushNoTopMenu=0", "accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "upgrade-insecure-requests" "1", "connection" "keep-alive", "user-agent" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36", "host" "localhost:8000", "accept-encoding" "gzip, deflate, sdch", "accept-language" "en-GB,en-US;q=0.8,en;q=0.6"}
INFO  onelog.core: Finished :get / for 127.0.0.1 in (13 ms) Status: 302 redirect to /info
INFO  onelog.core: Starting :get /info for 127.0.0.1 {"cookie" "plushContainerWidth=100%25; plushMultiOps=1; plushNoTopMenu=0", "accept" "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "upgrade-insecure-requests" "1", "connection" "keep-alive", "user-agent" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36", "host" "localhost:8000", "accept-encoding" "gzip, deflate, sdch", "accept-language" "en-GB,en-US;q=0.8,en;q=0.6"}
INFO  onelog.core: Finished :get /info for 127.0.0.1 in (5 ms) Status: 200

I'm going to create a config/ directory and add it to the CLASSPATH because putting log4j.properties in src/ feels like pollution.

pjlegato commented 9 years ago

I haven't gotten this error myself -- maybe it's only present in certain library versions?

If we have to add a log4j.properties, I'm inclined to put it into Onelog (the underlying logging library used by ring.middleware.logger.)

Does anyone know why only some people seem to get these warnings?

codeitagile commented 9 years ago

Maybe those people not getting errors have log4j.properties files somewhere in the their CLASSPATH but are unaware of it.

Perhaps run the following under lein repl to validate which log4j.properties individual applications are using, and reason from there:

(.getResource (java.lang.ClassLoader/getSystemClassLoader) "log4j.properties") 
;= #object[java.net.URL 0x17e3a2d1 "file:/home/mark/Projects/generic/clojure/base/src/log4j.properties"]

No log4j.properties files were in my CLASSPATH until I add it to src/ in my project. @pjlegato, I think your suggestion of adding a default log4j.properties file into Onelog sounds reasonable so long as there are no surprises due to it not being "found" first, and as such a different set of properties being applied than those expected.

I think it would be helpful to be able to specify a configuration (e.g. log level) at runtime and for everything to just work.

UPDATE: I just found clj-logging-config which seems to shine further light on the subject of configuration and searching of the CLASSPATH. I understand that ring-middleware-logger is using this already.