[Geoserver-devel] redirecting system.out and system.err

One thing that always causes questions is our standard JAI stack trace.

Error: Could not find mediaLib accelerator wrapper classes. Continuing in pure Java mode.
Occurs in: com.sun.media.jai.mlib.MediaLibAccessor
java.lang.NoClassDefFoundError: com/sun/medialib/mlib/Image
at com.sun.media.jai.mlib.MediaLibAccessor$1.run(MediaLibAccessor.java:248)
at java.security.AccessController.doPrivileged(Native Method)

etc…

I wonder if this article https://blogs.oracle.com/nickstephen/entry/java_redirecting_system_out_and could help us capture this output (and filter it out?).

Jody Garnett

Looks like another approach would be to register a JAI listener:

see line 280 in https://java.net/projects/jai-core/sources/svn/content/trunk/src/share/classes/com/sun/media/jai/mlib/MediaLibAccessor.java?rev=111

···

On Wed, Apr 16, 2014 at 9:12 AM, Jody Garnett <jody.garnett@anonymised.com> wrote:

One thing that always causes questions is our standard JAI stack trace.

Error: Could not find mediaLib accelerator wrapper classes. Continuing in pure Java mode.
Occurs in: com.sun.media.jai.mlib.MediaLibAccessor
java.lang.NoClassDefFoundError: com/sun/medialib/mlib/Image
at com.sun.media.jai.mlib.MediaLibAccessor$1.run(MediaLibAccessor.java:248)
at java.security.AccessController.doPrivileged(Native Method)

etc…

I wonder if this article https://blogs.oracle.com/nickstephen/entry/java_redirecting_system_out_and could help us capture this output (and filter it out?).

Jody Garnett


Learn Graph Databases - Download FREE O’Reilly Book
“Graph Databases” is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech


Geoserver-devel mailing list
Geoserver-devel@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Ian Schneider
Software Engineer | Boundless
ischneider@anonymised.com

On Wed, Apr 16, 2014 at 5:12 PM, Jody Garnett <jody.garnett@anonymised.com>wrote:

One thing that always causes questions is our standard JAI stack trace.

Error: Could not find mediaLib accelerator wrapper classes. Continuing in
pure Java mode.
Occurs in: com.sun.media.jai.mlib.MediaLibAccessor
java.lang.NoClassDefFoundError: com/sun/medialib/mlib/Image
at com.sun.media.jai.mlib.MediaLibAccessor$1.run(MediaLibAccessor.java:248)
at java.security.AccessController.doPrivileged(Native Method)
        etc...

I wonder if this article
https://blogs.oracle.com/nickstephen/entry/java_redirecting_system_out_andcould help us capture this output (and filter it out?).

Seems like an interesting avenue. For the JAI one I'd follow Ian
suggestion, but of course that one won't tap
other sysout that might have been left in the code by mistake.

So I'd also be good with the one you propose, with a few observations.
Geoserver can be deployed
along other applications, overriding the out is probably going to affect
everybody,
and it might be "nasty" to have other apps outs and errs in our logs only.
Also, the method you are going to use can throw a SecurityException (
http://docs.oracle.com/javase/6/docs/api/java/lang/System.html#setOut(java.io.PrintStream)
)
and I bet in some enviroments it will.
Long story short:
* it must be possible to de-activate the system out/err redirect to logs
* we should guard the attempt to redirect them in a try/catch to avoid
geoserver startup issues in locked down environments

Also, not sure what is going to happen if we re-init the logging system at
runtime
when someone changes the logging levels from the GUI, that is, are we going
to lose
the loggers used to redirect out and err, or are they maybe ignoring the
new logging
settings, and so on (maybe not, but we should check).

Cheers
Andrea

--

Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

I am pleased with Ian’s suggestion, as the JAI stack traces that cannot be avoided is what I am trying to cut down on.
Messing with standard out sounds very risky.

​Jody

Just to confirm I have tried out adding a listener, in GeoTools init() and it helpfully cleans up the log.

···

Jody Garnett

On Thu, Apr 17, 2014 at 2:21 AM, Jody Garnett <jody.garnett@anonymised.com> wrote:

I am pleased with Ian’s suggestion, as the JAI stack traces that cannot be avoided is what I am trying to cut down on.
Messing with standard out sounds very risky.


Jody

On Mon, May 12, 2014 at 8:57 PM, Jody Garnett <jody.garnett@anonymised.com>wrote:

Just to confirm I have tried out adding a listener, in GeoTools init() and
it helpfully cleans up the log.

Good, let's do that then. Wondering... is GeoServer calling GeoTools init
method anywhere?
I guess the place would be GeoServerInitStartupListener

Cheers
Andrea

--

Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Actually I just checked and it is not, although I have not checked if Spring calls it. I assume it should be called where all the other init logic is.

···

Jody Garnett

On Mon, May 12, 2014 at 12:52 PM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Mon, May 12, 2014 at 8:57 PM, Jody Garnett <jody.garnett@anonymised.com> wrote:

Just to confirm I have tried out adding a listener, in GeoTools init() and it helpfully cleans up the log.

Good, let’s do that then. Wondering… is GeoServer calling GeoTools init method anywhere?
I guess the place would be GeoServerInitStartupListener

Cheers

Andrea

==
Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Mon, May 12, 2014 at 9:59 PM, Jody Garnett <jody.garnett@anonymised.com>wrote:

Actually I just checked and it is not, although I have not checked if
Spring calls it. I assume it should be called where all the other init
logic is.

Yes, most of the initialization that we have to do before the "show" starts
is done inside GeoServerInitStartupListener,
it is called before the spring context initialization happens

Cheers
Andrea

--

Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Just finished a full GeoTools build with the change applied, will issue a pull request now.

···

Jody Garnett

On Mon, May 12, 2014 at 1:01 PM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Mon, May 12, 2014 at 9:59 PM, Jody Garnett <jody.garnett@anonymised.com> wrote:

Actually I just checked and it is not, although I have not checked if Spring calls it. I assume it should be called where all the other init logic is.

Yes, most of the initialization that we have to do before the “show” starts is done inside GeoServerInitStartupListener,
it is called before the spring context initialization happens

Cheers

Andrea

==
Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Actually can you think of a way to get GeoTools init called in our test cases? It would really cut down on the logs when I run locally.

···

Jody Garnett

On Mon, May 12, 2014 at 1:02 PM, Jody Garnett <jody.garnett@anonymised.com> wrote:

Just finished a full GeoTools build with the change applied, will issue a pull request now.

Jody Garnett

On Mon, May 12, 2014 at 1:01 PM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Mon, May 12, 2014 at 9:59 PM, Jody Garnett <jody.garnett@anonymised.com.> wrote:

Actually I just checked and it is not, although I have not checked if Spring calls it. I assume it should be called where all the other init logic is.

Yes, most of the initialization that we have to do before the “show” starts is done inside GeoServerInitStartupListener,
it is called before the spring context initialization happens

Cheers

Andrea

==
Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Mon, May 12, 2014 at 10:02 PM, Jody Garnett <jody.garnett@anonymised.com>wrote:

Actually can you think of a way to get GeoTools init called in our test
cases? It would really cut down on the logs when I run locally.

You mean in the Geotools tests? Nope, they are all spread out, no structure.
In the GeoServer ones instead? Most of them are based on the same base
class, just put it there

Cheers
Andrea

--

Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------