logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimer Shioshvili <vshioshv...@qrc.com>
Subject Re: tomcat and log4j, again
Date Thu, 03 Jul 2003 17:06:56 GMT
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 

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 

and respectively 
For example, %d{ISO8601} or %d{ABSOLUTE}.

These dedicated date formatters perform significantly better than 

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.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?
>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 
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message