You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Magnus Vojbacke (KA/EAB)" <ma...@ericsson.com> on 2007/09/11 16:38:01 UTC

Embedded Apache Tomcat/5.5.9 outputting to java.util.logging instead of console

Problem at hand:
Embedding tomcat into our server, we get the occasional info and warning
while tomcat is starting. In our current configuration, these messages
are fed to the console. Although the warnings do not affect the
performance of our product, they are confusing to our users.

Now, I'd like to output _everything_ from tomcat to a logfile instead of
the console, and I do _not_ want to use log4j. Any other method is fine,
and java.util.logging would be prefereable (this shouldn't be a problem
with commons-logging, right?). I've googled terms like "embedded tomcat
java.util.logging" and less specific terms since yesterday, and there's
tons of info on how to configure tomcat logging. But it all seems to be
for file-configuration of "regular" tomcat installations (as opposed to
embedded), and I haven't gotten any of the examples to work. I've also
tried to alter our invocation of tomcat, but alas I have not found any
way in the API of supplying an existing Logger-object or define which
logger object to use programatically either.

So, how do I set up tomcat to log _everything_ to commons-logging ->
java.util.logging.Logger? Can this be configured by config-files (which
ones, and how???), or do I have to make these settings from our invoking
code? Does anyone know of any how-tos or guides that touch on the issue
of logging from embedded tomcat?

/Magnus

RE: Embedded Apache Tomcat/5.5.9 outputting to java.util.logging instead of console

Posted by Magnus Vojbacke <ma...@ericsson.com>.
Yo,

Actually the Embedded version in 5.5.9 does not utilize the
Logger-objects (I believe they changed that in 5.5?), but no matter
since I managed to kind of get it working. As soon as I got it through
my thick skull that Tomcat was executing in the same JVM as my
application it was just a matter of creating a logger with the namespace
"apache.org" and give it a filehandler before invoking apache! God, I've
wasted some serious time on this! :)

Thanks for the help
/Magnus V

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: den 12 september 2007 17:29
To: Tomcat Users List
Subject: Re: Embedded Apache Tomcat/5.5.9 outputting to
java.util.logging instead of console

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Filip,

The OP is using embedded TC, so there's no script.

> Magnus Vojbacke (KA/EAB) wrote:
>>> Are they inspecting catalina.out? If so, what will stop them from
>>>     
>> reading whatever /other/ logfile you choose?
>>
>> No, there _is_ no catalina.out anywhere in my tomcat folder or the 
>> child folders thereof. Everything is output to console. Probably 
>> should have mentioned that, since it's a little weird...

Are you using the Embedded class to embed Tomcat? Can you show us how
you are using it? The instance, the Embedded class constructor accepts a
Logger object that might be useful for this.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG6AXE9CaO5/Lv0PARAs8SAJ9poc/582bzKsYOeIR6/D3ZmzsqcQCfbkRd
ER15sNHsJD/+cP9VZbZR6c8=
=xv99
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Embedded Apache Tomcat/5.5.9 outputting to java.util.logging instead of console

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Filip,

The OP is using embedded TC, so there's no script.

> Magnus Vojbacke (KA/EAB) wrote:
>>> Are they inspecting catalina.out? If so, what will stop them from
>>>     
>> reading whatever /other/ logfile you choose?
>>
>> No, there _is_ no catalina.out anywhere in my tomcat folder or the child
>> folders thereof. Everything is output to console. Probably should have
>> mentioned that, since it's a little weird...

Are you using the Embedded class to embed Tomcat? Can you show us how
you are using it? The instance, the Embedded class constructor accepts a
Logger object that might be useful for this.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG6AXE9CaO5/Lv0PARAs8SAJ9poc/582bzKsYOeIR6/D3ZmzsqcQCfbkRd
ER15sNHsJD/+cP9VZbZR6c8=
=xv99
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Embedded Apache Tomcat/5.5.9 outputting to java.util.logging instead of console

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Magnus Vojbacke (KA/EAB) wrote:
>> Are they inspecting catalina.out? If so, what will stop them from
>>     
> reading whatever /other/ logfile you choose?
>
> No, there _is_ no catalina.out anywhere in my tomcat folder or the child
> folders thereof. Everything is output to console. Probably should have
> mentioned that, since it's a little weird...
>   
catalina.out is the pipe of std.out/std.err, but maybe in your system, 
you haven't piped std.err or out,

 > catalina.out 2>&1

tomcat itself, doesn't write a file called catalina.out, this is just a 
pipe in the catalina.sh script

Filip


> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Embedded Apache Tomcat/5.5.9 outputting to java.util.logging instead of console

Posted by "Magnus Vojbacke (KA/EAB)" <ma...@ericsson.com>.
> Are they inspecting catalina.out? If so, what will stop them from
reading whatever /other/ logfile you choose?

No, there _is_ no catalina.out anywhere in my tomcat folder or the child
folders thereof. Everything is output to console. Probably should have
mentioned that, since it's a little weird...

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Embedded Apache Tomcat/5.5.9 outputting to java.util.logging instead of console

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Magnus,

Magnus Vojbacke (KA/EAB) wrote:
> Although the warnings do not affect the
> performance of our product, they are confusing to our users.

Are they inspecting catalina.out? If so, what will stop them from
reading whatever /other/ logfile you choose?

> Now, I'd like to output _everything_ from tomcat to a logfile instead of
> the console, and I do _not_ want to use log4j.

Why no log4j? Philosophical disagreement?

> Any other method is fine,
> and java.util.logging would be prefereable (this shouldn't be a problem
> with commons-logging, right?).

Right. Commons-logging uses java.util.logging by default, I think, if
log4j isn't available.

Since you're starting Tomcat embedded, you ought to be able to control
standard output. Just wire standard output into a file instead of
allowing it to dump to the console.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG5rD79CaO5/Lv0PARAuM+AKCi/Kn1a4j7S6aOKSnLUOOvMg85iQCbBmLt
dqRdlSbVD24lkXhe+9xLQYY=
=xR2a
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Embedded Apache Tomcat/5.5.9 outputting to java.util.logging instead of console

Posted by Bill Barker <wb...@wilshire.com>.
Chris is correct, Tomcat will use java.util.logging if it doesn't find log4j 
(and TC 6 won't even look for log4j by default).  So all you have to do is 
to configure java.util.logging for your application.  If you want to use 
Tomcat's Juli implementation, then you need to configure that for your 
entire application as well by starting it with:
   -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

"Magnus Vojbacke (KA/EAB)" <ma...@ericsson.com> wrote in message 
news:80578AD4A7B0C843B70EAC6FE8FA9A9C28B657@esealmw111...
Problem at hand:
Embedding tomcat into our server, we get the occasional info and warning
while tomcat is starting. In our current configuration, these messages
are fed to the console. Although the warnings do not affect the
performance of our product, they are confusing to our users.

Now, I'd like to output _everything_ from tomcat to a logfile instead of
the console, and I do _not_ want to use log4j. Any other method is fine,
and java.util.logging would be prefereable (this shouldn't be a problem
with commons-logging, right?). I've googled terms like "embedded tomcat
java.util.logging" and less specific terms since yesterday, and there's
tons of info on how to configure tomcat logging. But it all seems to be
for file-configuration of "regular" tomcat installations (as opposed to
embedded), and I haven't gotten any of the examples to work. I've also
tried to alter our invocation of tomcat, but alas I have not found any
way in the API of supplying an existing Logger-object or define which
logger object to use programatically either.

So, how do I set up tomcat to log _everything_ to commons-logging ->
java.util.logging.Logger? Can this be configured by config-files (which
ones, and how???), or do I have to make these settings from our invoking
code? Does anyone know of any how-tos or guides that touch on the issue
of logging from embedded tomcat?

/Magnus




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org