You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Dean A. Hoover" <dh...@rochester.rr.com> on 2003/07/03 18:54:58 UTC

tomcat and log4j, again

OK, with my current configuration, I *am* seeing
output in catalina.out. However, its not formatted
the way I (think I) told it to. Also, I would
prefer to have the output go to a separate log
file, as there is just too much stuff in catalina.out
to wade through.

Anyway, I am using RH9, jakarta-tomcat-4.1.24,
and log4j-1.2.8. For my webapp, I am
creating a war file that has log4j.properties
in the WEB-INF/classes directory. I dropped
log4j-1.2.8.jar into the WEB-INF/lib directory.

The log4j.properties file looks like this:

log4j.logger.fermataintl.migrasponder=DEBUG, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d [%t] %-5p %F:%L - %m%n
=================================================================

I am not explicitly initializing log4j. A class that I am using
in my app invokes logging as follows:

package fermataintl.migrasponder.common;
import java.sql.*;
import org.apache.log4j.*;

public class Vendor
{
...
     logger.warn("attempt to authenticate '" + id + "' failed");
...
     private static Logger logger = Logger.getLogger(Vendor.class);
}
==================================================================

When I run my app and exercise the bit of code containing the
warning above, it puts the following in catalina.out:

1571947 [Thread-5] WARN common.Vendor  - attempt to authenticate 'xxx' 
failed
===================================================================
So... my questions are:

1) How do I get output to a file of my own choosing
2) How do I get the formatting to come out with date and time prepended?

Thanks.
Dean Hoover

PS. I looked for the commercial manual (on the website) at 2 local 
bookstores and on amazon.com. Nobody has it. I hesitate to order from
Switzerland, as I am in the US. How long would that take...


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: tomcat and log4j, again

Posted by Vladimer Shioshvili <vs...@qrc.com>.
PS. WRAX press' Tomcat book has a section on Log4J. Pretty simple, 20 pages 
tops, but it will get you started. If you can get a handle of that, of course.

At 12:54 PM 7/3/2003, you wrote:
>OK, with my current configuration, I *am* seeing
>output in catalina.out. However, its not formatted
>the way I (think I) told it to. Also, I would
>prefer to have the output go to a separate log
>file, as there is just too much stuff in catalina.out
>to wade through.
>
>Anyway, I am using RH9, jakarta-tomcat-4.1.24,
>and log4j-1.2.8. For my webapp, I am
>creating a war file that has log4j.properties
>in the WEB-INF/classes directory. I dropped
>log4j-1.2.8.jar into the WEB-INF/lib directory.
>
>The log4j.properties file looks like this:
>
>log4j.logger.fermataintl.migrasponder=DEBUG, console
>log4j.appender.console=org.apache.log4j.ConsoleAppender
>log4j.appender.console.layout=org.apache.log4j.PatternLayout
>log4j.appender.console.layout.ConversionPattern=%d [%t] %-5p %F:%L - %m%n
>=================================================================
>
>I am not explicitly initializing log4j. A class that I am using
>in my app invokes logging as follows:
>
>package fermataintl.migrasponder.common;
>import java.sql.*;
>import org.apache.log4j.*;
>
>public class Vendor
>{
>...
>     logger.warn("attempt to authenticate '" + id + "' failed");
>...
>     private static Logger logger = Logger.getLogger(Vendor.class);
>}
>==================================================================
>
>When I run my app and exercise the bit of code containing the
>warning above, it puts the following in catalina.out:
>
>1571947 [Thread-5] WARN common.Vendor  - attempt to authenticate 'xxx' failed
>===================================================================
>So... my questions are:
>
>1) How do I get output to a file of my own choosing
>2) How do I get the formatting to come out with date and time prepended?
>
>Thanks.
>Dean Hoover
>
>PS. I looked for the commercial manual (on the website) at 2 local 
>bookstores and on amazon.com. Nobody has it. I hesitate to order from
>Switzerland, as I am in the US. How long would that take...
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>

________________
Vladimer Shioshvili

QRC Division of Macro International Inc.
7315 Wisconsin Avenue, Suite 400W
Bethesda, MD 20814

Phone: (301) 657 3077 ext. 155 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: tomcat and log4j, again

Posted by Ceki Gülcü <ce...@qos.ch>.
At 12:54 PM 7/3/2003 -0400, Dean A. Hoover wrote:

>PS. I looked for the commercial manual (on the website) at 2 local 
>bookstores and on amazon.com. Nobody has it. I hesitate to order from
>Switzerland, as I am in the US. How long would that take...

You can "The complete log4j manual" in the US from Softpro books:

   http://store.yahoo.com/softpro/2-9700369-0-8.html

They should have it in stock.

Otherwise, your hesitation about purchasing the book from Switzerland
is quite normal. Of course, much of the log4j code was written in
Switzerland as anyone can guess from the cheesy smell of the code.
People in Switzerland are notorious for their feet and the cheesy
smell they exude.  Some say that it is the Swiss feet that give the
cheese its uniquely rich aroma and flavor, or maybe it is the other
way around...

Interestingly enough, while visiting the US on vacation, a waitress
asked us what kind of cheese we wanted in our sandwich. She listed
the various sorts and we stopped her as soon as she pronounced the words
"Swiss cheese". We enthusiastically repeated "Swiss cheese" with a
twinkle in our eyes, yearning for the Gruyere or possibly the Vacherin
fribourgeois that we enjoy so much.  Talk about a cultural shock when
we realized that "Swiss cheese" in the US means a gooey slice of
plastic with holes in it. To be fair, it loosely resembled the
Emmental but that is probably stretching the word "loosely."

Anyway, we loved every minute of our visit, although there were a few
rare exceptions which are better kept unshared.

If you are wondering if I've lost a marble or two during my stay in
London, I've been sick since my return. And the Apache rules
specifically state** everyone is allowed to go on a tangent once in a
decade. It's my turn. :-)

** If you don't believe me, read the ASF bylaws. It's around section
43 or thereabouts.

--
Ceki  For log4j documentation consider "The complete log4j manual"
       ISBN: 2970036908  http://www.qos.ch/shop/products/clm_t.jsp 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: tomcat and log4j, again

Posted by Vladimer Shioshvili <vs...@qrc.com>.
1. look into using fileappenders, or even better rolling file appenders.
2. in the log4j api find patternlayout. it has very good documentation.


d Used to output the date of the logging event. The date conversion 
specifier may be followed by a date format specifier enclosed between 
braces. For example, %d{HH:mm:ss,SSS} or %d{dd MMM yyyy HH:mm:ss,SSS}. If 
no date format specifier is given then ISO8601 format is assumed.

The date format specifier admits the same syntax as the time pattern string 
of the 
<http://java.sun.com/products/jdk/1.3/docs/api/java/text/SimpleDateFormat.html>SimpleDateFormat. 
Although part of the standard JDK, the performance of SimpleDateFormat is 
quite poor.

For better results it is recommended to use the log4j date formatters. 
These can be specified using one of the strings "ABSOLUTE", "DATE" and 
"ISO8601" for specifying 
<../../../org/apache/log4j/helpers/AbsoluteTimeDateFormat.htm>AbsoluteTimeDateFormat, 
<../../../org/apache/log4j/helpers/DateTimeDateFormat.htm>DateTimeDateFormat 
and respectively 
<../../../org/apache/log4j/helpers/ISO8601DateFormat.htm>ISO8601DateFormat. 
For example, %d{ISO8601} or %d{ABSOLUTE}.

These dedicated date formatters perform significantly better than 
<http://java.sun.com/products/jdk/1.3/docs/api/java/text/SimpleDateFormat.html>SimpleDateFormat. 


Hope this helps

At 12:54 PM 7/3/2003, you wrote:
>OK, with my current configuration, I *am* seeing
>output in catalina.out. However, its not formatted
>the way I (think I) told it to. Also, I would
>prefer to have the output go to a separate log
>file, as there is just too much stuff in catalina.out
>to wade through.
>
>Anyway, I am using RH9, jakarta-tomcat-4.1.24,
>and log4j-1.2.8. For my webapp, I am
>creating a war file that has log4j.properties
>in the WEB-INF/classes directory. I dropped
>log4j-1.2.8.jar into the WEB-INF/lib directory.
>
>The log4j.properties file looks like this:
>
>log4j.logger.fermataintl.migrasponder=DEBUG, console
>log4j.appender.console=org.apache.log4j.ConsoleAppender
>log4j.appender.console.layout=org.apache.log4j.PatternLayout
>log4j.appender.console.layout.ConversionPattern=%d [%t] %-5p %F:%L - %m%n
>=================================================================
>
>I am not explicitly initializing log4j. A class that I am using
>in my app invokes logging as follows:
>
>package fermataintl.migrasponder.common;
>import java.sql.*;
>import org.apache.log4j.*;
>
>public class Vendor
>{
>...
>     logger.warn("attempt to authenticate '" + id + "' failed");
>...
>     private static Logger logger = Logger.getLogger(Vendor.class);
>}
>==================================================================
>
>When I run my app and exercise the bit of code containing the
>warning above, it puts the following in catalina.out:
>
>1571947 [Thread-5] WARN common.Vendor  - attempt to authenticate 'xxx' failed
>===================================================================
>So... my questions are:
>
>1) How do I get output to a file of my own choosing
>2) How do I get the formatting to come out with date and time prepended?
>
>Thanks.
>Dean Hoover
>
>PS. I looked for the commercial manual (on the website) at 2 local 
>bookstores and on amazon.com. Nobody has it. I hesitate to order from
>Switzerland, as I am in the US. How long would that take...
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>

________________
Vladimer Shioshvili

QRC Division of Macro International Inc.
7315 Wisconsin Avenue, Suite 400W
Bethesda, MD 20814

Phone: (301) 657 3077 ext. 155