Home » Eclipse Projects » Equinox » problems by jetty bundle with log4j
|
Re: problems by jetty bundle with log4j [message #82139 is a reply to message #82121] |
Tue, 30 January 2007 17:51 |
Martin Dames Messages: 28 Registered: July 2009 |
Junior Member |
|
|
In article <m.dames-1091E2.18393130012007@news.eclipse.org>,
Martin Dames <m.dames@gmx.de> wrote:
> Hello all,
>
> Im running the jetty bundle with the equinox.http.jetty stuff...
> everytime I ran my OSGi launch conf I am getting the error:
>
> osgi> log4j:WARN No appenders could be found for logger
> (org.mortbay.util.Container).log4j:WARN Please initialize the log4j
> system properly.
>
> So, I know.. I need to set the log4j.properties file correct... I am
> using this:
>
> # Set root logger level to DEBUG and its only appender to
> A1.log4j.rootLogger=INFO, A1# A1 is set to be a
> ConsoleAppender.log4j.appender.A1=org.apache.log4j.ConsoleAp pender# A1
> uses
> PatternLayout.log4j.appender.A1.layout=org.apache.log4j.Patt ernLayoutlog4
> j.appender.A1.layout.ConversionPattern=%-4r %-5p %-18C{1} - %m%n#
> suppress jalopy logginglog4j.logger.de.hunsicker=ERROR
>
> my problem is now... wheres should I place the properties file, so that
> log4j, used by jetty can find it?
>
> I am also using spring... and spring is also using log4j, and my further
> bundles should use log4j as well... how can I configure each bundle
> seperatly for log4j?
>
> Thank you very much,
>
> Martin.
Before you ask... I forget some information to be said:
I put the logj4.properties file in the root of the bundle:
org.mortbay.jetty and told the manifest.mf that it should use the
Bundle-Classpath ., log4j.properties
I also tried to put it to some log related packages (org.mortbay.util,
org.mortbay.log) and to the META-INF dir...
but nothing.. I am getting the error..
Then I tried to put the file to the bundle:
org.eclipse.equinox.http.jetty, I did the same Bundle-Classpath there...
but nothing... ?
Thank you.
|
|
|
Re: problems by jetty bundle with log4j [message #82154 is a reply to message #82139] |
Tue, 30 January 2007 23:59 |
Eclipse User |
|
|
|
Originally posted by: alex_blewitt.yahoo.com
I seem to recall that you also need to have something like
Bundle-ExportPackage: .
or
Bundle-ExportPackage: log4j.properties
so that it's visible to the buddy classloader. Of course, if you have it in a subdirectory instead, then you'd use the directory name as the package.
Alex.
|
|
| |
Re: problems by jetty bundle with log4j [message #82183 is a reply to message #82169] |
Wed, 31 January 2007 14:50 |
Eclipse User |
|
|
|
Originally posted by: alex_blewitt.yahoo.com
Might be a ClassNotFoundException being generated when trying to instantiate a logger. That would give the observed behvaiour. You'll have to find out which bundle is trying to obtain the logging classes, and then set up a dependency between that and the log4j classes to put it on the classpath.
Alex.
|
|
| |
Re: problems by jetty bundle with log4j [message #82304 is a reply to message #82139] |
Wed, 31 January 2007 20:45 |
Simon Kaegi Messages: 22 Registered: July 2009 |
Junior Member |
|
|
Hi Martin,
I'm curious whereyour apache.commons.logging bundle came from?
I ask because the bundle in Orbit does not import log4j directly or
dynamically.
I'd suggest keeping your logging very simple as for the moment it's brittle
and static and does not support many of the dynamic use-case in OSGi
particularly well. That said, static scenarios are workable.
So, if you're determined to use log4j here's an approach (assuming you're
using the orbit copy of JCL and already have a log4j bundle):
1) Create a fragment of the apache.commons.logging that contains an
Import-Package: for org.apache.log4j
2) If your log4j bundle contains log4j.properties file augment it otherwise
add one either directly to the bundle (or perhaps as a fragment.)
AFAIK log4j allows the use of just one log4j.properties and that's why I'd
caution its use in non-static scenarios.
HTH
-Simon
"Martin Dames" <m.dames@gmx.de> wrote in message
news:m.dames-5CB77C.18515430012007@news.eclipse.org...
> In article <m.dames-1091E2.18393130012007@news.eclipse.org>,
> Martin Dames <m.dames@gmx.de> wrote:
>
>> Hello all,
>>
>> Im running the jetty bundle with the equinox.http.jetty stuff...
>> everytime I ran my OSGi launch conf I am getting the error:
>>
>> osgi> log4j:WARN No appenders could be found for logger
>> (org.mortbay.util.Container).log4j:WARN Please initialize the log4j
>> system properly.
>>
>> So, I know.. I need to set the log4j.properties file correct... I am
>> using this:
>>
>> # Set root logger level to DEBUG and its only appender to
>> A1.log4j.rootLogger=INFO, A1# A1 is set to be a
>> ConsoleAppender.log4j.appender.A1=org.apache.log4j.ConsoleAp pender# A1
>> uses
>> PatternLayout.log4j.appender.A1.layout=org.apache.log4j.Patt ernLayoutlog4
>> j.appender.A1.layout.ConversionPattern=%-4r %-5p %-18C{1} - %m%n#
>> suppress jalopy logginglog4j.logger.de.hunsicker=ERROR
>>
>> my problem is now... wheres should I place the properties file, so that
>> log4j, used by jetty can find it?
>>
>> I am also using spring... and spring is also using log4j, and my further
>> bundles should use log4j as well... how can I configure each bundle
>> seperatly for log4j?
>>
>> Thank you very much,
>>
>> Martin.
>
> Before you ask... I forget some information to be said:
>
> I put the logj4.properties file in the root of the bundle:
>
> org.mortbay.jetty and told the manifest.mf that it should use the
> Bundle-Classpath ., log4j.properties
>
> I also tried to put it to some log related packages (org.mortbay.util,
> org.mortbay.log) and to the META-INF dir...
>
> but nothing.. I am getting the error..
>
> Then I tried to put the file to the bundle:
> org.eclipse.equinox.http.jetty, I did the same Bundle-Classpath there...
>
> but nothing... ?
>
> Thank you.
|
|
| | |
Re: problems by jetty bundle with log4j [message #83712 is a reply to message #83665] |
Wed, 28 February 2007 09:51 |
Martin Dames Messages: 28 Registered: July 2009 |
Junior Member |
|
|
Hi Paul,
yes, it runs fine now. I used the log4j bundle from spring-osgi, but it
should run with any other log4j bundle as well.
The trick is, that you have to put the log4j.properties file in the
log4j bundle itself. My bundle looks like this:
-log4j.osgi
/META-INF
-MANIFEST.MF
/TARGET
/CLASSES
/log4j packages...
-log4j.properties
I am using the commons.logging bundle also from spring, because the one
from Equinox/JSP is outdated and the one from spring is newer and uses
log4j as priority.
When everything is correct you should get an log output like this after
starting jetty:
10:49:29.419 DEBUG[org.mortbay.util.Container] add component:
SocketListener0@0.0.0.0:8081
10:49:29.436 DEBUG[org.mortbay.util.Container] add component:
org.eclipse.equinox.http.jetty.internal.HttpServerManager$In ternalHttpServiceServlet
10:49:29.452 DEBUG[org.mortbay.util.Container] add component:
org.mortbay.http.ResourceCache@59aa86
10:49:29.458 DEBUG[org.mortbay.util.Container] add component:
org.mortbay.jetty.servlet.HashSessionManager@8b41da
10:49:29.458 DEBUG[org.mortbay.util.Container] add component:
org.mortbay.jetty.servlet.ServletHandler@908558
10:49:29.459 DEBUG[org.mortbay.util.Container] add component:
HttpContext[/,/]
10:49:29.460 DEBUG[org.mortbay.http.HttpServer] Added HttpContext[/,/]
for host *
10:49:29.460 DEBUG[org.mortbay.util.Container] Starting
org.mortbay.http.HttpServer@15fbb0
10:49:29.461 INFO [org.mortbay.http.HttpServer] Version Jetty/5.1.x
10:49:29.462 DEBUG[org.mortbay.http.HttpServer] LISTENERS:
[SocketListener0@0.0.0.0:8081]
10:49:29.462 DEBUG[org.mortbay.http.HttpServer] HANDLER:
{null={/=[HttpContext[/,/]]}}
10:49:29.463 DEBUG[org.mortbay.util.Container] Starting HttpContext[/,/]
10:49:29.463 DEBUG[org.mortbay.util.Container] Starting
org.mortbay.jetty.servlet.ServletHandler@908558
10:49:29.463 DEBUG[org.mortbay.jetty.servlet.AbstractSessionManager] New
random session seed
10:49:29.465 DEBUG[org.mortbay.jetty.servlet.AbstractSessionManager]
Session scavenger period = 30s
10:49:29.465 DEBUG[org.mortbay.jetty.servlet.Holder] Started holder of
class
org.eclipse.equinox.http.jetty.internal.HttpServerManager$In ternalHttpServiceServlet
10:49:29.555 DEBUG[org.apache.jasper.compiler.JspRuntimeContext] Parent
class loader is:
org.eclipse.equinox.internal.jsp.jasper.JspClassLoader@b35955
10:49:29.555 DEBUG[org.apache.jasper.compiler.JspRuntimeContext]
Compilation classpath initialized:
/Users/martin/Documents/Development/EclipseWorkspaces/OSGIWo rkspace6/.metadata/.plugins/org.eclipse.pde.core/New_configu ration/org.eclipse.osgi/bundles/52/data/jettywork/pid_154480 3905/proxytemp/hc_1688690:null
10:49:29.556 DEBUG[org.mortbay.jetty.servlet.ServletHandler] getRealPath
of / in org.mortbay.jetty.servlet.ServletHandler@908558
10:49:29.559 DEBUG[org.apache.jasper.servlet.JspServlet] Scratch dir for
the JSP engine is:
/Users/martin/Documents/Development/EclipseWorkspaces/OSGIWo rkspace6/.metadata/.plugins/org.eclipse.pde.core/New_configu ration/org.eclipse.osgi/bundles/52/data/jettywork/pid_154480 3905/proxytemp/hc_1688690
10:49:29.559 DEBUG[org.apache.jasper.servlet.JspServlet] IMPORTANT: Do
not modify the generated servlets
....
the last ones are from jasper and only there if you are using the JSP
solution from Equinox/Server.
Jetty also logs GET/POST messages pretty well.
Hope that helped.
Paul Gardiner schrieb:
> Did you ever figure this out? I'm having the same issue.
>
> "Martin Dames" <m.dames@gmx.de> wrote in message
> news:abeab39889a95f51ce787a89aca497bd$1@www.eclipse.org...
>> Hey,
>>
>> thank you guys for the comments... but it wont run.. well.. I uploaded an
>> easy workspace with a simple example with a servlet and an index.htm file.
>> It runs very well but log4j is complaining... please download the
>> workspace and try something out... I tried a lot but nothing helped.
>>
>> Simon, thank you for the hints... that answered a bit my question how to
>> log osgi-globally wide with log4j... unfortunately you said it a bit
>> hacky... maybe you have another hint how bundles can log easily with own
>> appenders in a central way? It should run with Spring (Spring-OSGi).
>>
>> You can unpack the zip (21MB) and switch the workspace to it. I dont know
>> if my launch configuration is included too, but I think it should... so
>> you need just to press the Run button in the best case.
>>
>> For all Windows Users: The Workspace is created with a Mac and should
>> contain no viruses.
>>
>>
>> http://rapidshare.com/files/14625017/OSGIWorkspace4.zip
>>
>>
>> Thank you again, and I am looking forward for an explanation! :-)
>>
>> Martin.
>>
>
>
|
|
|
Re: problems by jetty bundle with log4j [message #83728 is a reply to message #83712] |
Wed, 28 February 2007 15:29 |
Paul Gardiner Messages: 94 Registered: July 2009 |
Member |
|
|
I had already done that and it still didn't work. Actually, I created a
fragment of the log4j bundle, and put my properties file in there, but same
effect.
It turns out that my problem was caused by a badly behaving plugin. The
org.eclipse.teneo.libraries plugin has commons-logging.jar and
log4j-1.2.8.jar right in the plugin. That's not the end of the world, but
then they export the entire thing. The jetty bundle imports commons-logging
through an Import-Package, and it was finding the package in the teneo
library bundle. To work around it, I changed the jetty bundle to use
Require-Bunlde instead if Import-Package, and now it gets configured
correctly.
"Martin Dames" <m.dames@gmx.de> wrote in message
news:es3jb5$83i$1@utils.eclipse.org...
> Hi Paul,
>
>
> yes, it runs fine now. I used the log4j bundle from spring-osgi, but it
> should run with any other log4j bundle as well.
>
> The trick is, that you have to put the log4j.properties file in the log4j
> bundle itself. My bundle looks like this:
>
> -log4j.osgi
> /META-INF
> -MANIFEST.MF
> /TARGET
> /CLASSES
> /log4j packages...
> -log4j.properties
>
>
> I am using the commons.logging bundle also from spring, because the one
> from Equinox/JSP is outdated and the one from spring is newer and uses
> log4j as priority.
>
> When everything is correct you should get an log output like this after
> starting jetty:
>
> 10:49:29.419 DEBUG[org.mortbay.util.Container] add component:
> SocketListener0@0.0.0.0:8081
> 10:49:29.436 DEBUG[org.mortbay.util.Container] add component:
> org.eclipse.equinox.http.jetty.internal.HttpServerManager$In ternalHttpServiceServlet
> 10:49:29.452 DEBUG[org.mortbay.util.Container] add component:
> org.mortbay.http.ResourceCache@59aa86
> 10:49:29.458 DEBUG[org.mortbay.util.Container] add component:
> org.mortbay.jetty.servlet.HashSessionManager@8b41da
> 10:49:29.458 DEBUG[org.mortbay.util.Container] add component:
> org.mortbay.jetty.servlet.ServletHandler@908558
> 10:49:29.459 DEBUG[org.mortbay.util.Container] add component:
> HttpContext[/,/]
> 10:49:29.460 DEBUG[org.mortbay.http.HttpServer] Added HttpContext[/,/] for
> host *
> 10:49:29.460 DEBUG[org.mortbay.util.Container] Starting
> org.mortbay.http.HttpServer@15fbb0
> 10:49:29.461 INFO [org.mortbay.http.HttpServer] Version Jetty/5.1.x
> 10:49:29.462 DEBUG[org.mortbay.http.HttpServer] LISTENERS:
> [SocketListener0@0.0.0.0:8081]
> 10:49:29.462 DEBUG[org.mortbay.http.HttpServer] HANDLER:
> {null={/=[HttpContext[/,/]]}}
> 10:49:29.463 DEBUG[org.mortbay.util.Container] Starting HttpContext[/,/]
> 10:49:29.463 DEBUG[org.mortbay.util.Container] Starting
> org.mortbay.jetty.servlet.ServletHandler@908558
> 10:49:29.463 DEBUG[org.mortbay.jetty.servlet.AbstractSessionManager] New
> random session seed
> 10:49:29.465 DEBUG[org.mortbay.jetty.servlet.AbstractSessionManager]
> Session scavenger period = 30s
> 10:49:29.465 DEBUG[org.mortbay.jetty.servlet.Holder] Started holder of
> class
> org.eclipse.equinox.http.jetty.internal.HttpServerManager$In ternalHttpServiceServlet
> 10:49:29.555 DEBUG[org.apache.jasper.compiler.JspRuntimeContext] Parent
> class loader is:
> org.eclipse.equinox.internal.jsp.jasper.JspClassLoader@b35955
> 10:49:29.555 DEBUG[org.apache.jasper.compiler.JspRuntimeContext]
> Compilation classpath initialized:
> /Users/martin/Documents/Development/EclipseWorkspaces/OSGIWo rkspace6/.metadata/.plugins/org.eclipse.pde.core/New_configu ration/org.eclipse.osgi/bundles/52/data/jettywork/pid_154480 3905/proxytemp/hc_1688690:null
> 10:49:29.556 DEBUG[org.mortbay.jetty.servlet.ServletHandler] getRealPath
> of / in org.mortbay.jetty.servlet.ServletHandler@908558
> 10:49:29.559 DEBUG[org.apache.jasper.servlet.JspServlet] Scratch dir for
> the JSP engine is:
> /Users/martin/Documents/Development/EclipseWorkspaces/OSGIWo rkspace6/.metadata/.plugins/org.eclipse.pde.core/New_configu ration/org.eclipse.osgi/bundles/52/data/jettywork/pid_154480 3905/proxytemp/hc_1688690
> 10:49:29.559 DEBUG[org.apache.jasper.servlet.JspServlet] IMPORTANT: Do not
> modify the generated servlets
> ...
>
>
> the last ones are from jasper and only there if you are using the JSP
> solution from Equinox/Server.
>
> Jetty also logs GET/POST messages pretty well.
>
> Hope that helped.
>
>
>
> Paul Gardiner schrieb:
>> Did you ever figure this out? I'm having the same issue.
>>
>> "Martin Dames" <m.dames@gmx.de> wrote in message
>> news:abeab39889a95f51ce787a89aca497bd$1@www.eclipse.org...
>>> Hey,
>>>
>>> thank you guys for the comments... but it wont run.. well.. I uploaded
>>> an easy workspace with a simple example with a servlet and an index.htm
>>> file. It runs very well but log4j is complaining... please download the
>>> workspace and try something out... I tried a lot but nothing helped.
>>>
>>> Simon, thank you for the hints... that answered a bit my question how to
>>> log osgi-globally wide with log4j... unfortunately you said it a bit
>>> hacky... maybe you have another hint how bundles can log easily with own
>>> appenders in a central way? It should run with Spring (Spring-OSGi).
>>>
>>> You can unpack the zip (21MB) and switch the workspace to it. I dont
>>> know if my launch configuration is included too, but I think it
>>> should... so you need just to press the Run button in the best case.
>>>
>>> For all Windows Users: The Workspace is created with a Mac and should
>>> contain no viruses.
>>>
>>>
>>> http://rapidshare.com/files/14625017/OSGIWorkspace4.zip
>>>
>>>
>>> Thank you again, and I am looking forward for an explanation! :-)
>>>
>>> Martin.
>>>
>>
|
|
|
Goto Forum:
Current Time: Fri Apr 26 09:44:59 GMT 2024
Powered by FUDForum. Page generated in 0.03890 seconds
|