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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


________________ Vladimer Shioshvili

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

Phone: (301) 657 3077 ext. 155

Reply via email to