Hello Mates:=0A=0AI got the log file to work however, it does not have the =
date appended like the usual Tomcat Logs and does not creating a rolling da=
ily file. I also wanted to have control over the usual logs that Tomcat pro=
duced so I combined your instructions with those from this other website at=
http://mrhaki.blogspot.com/2011/02/configure-log4j-on-tomcat.html to get t=
he content for the properties file. However, the problems are:=0A=09* the l=
og files do not have the .log extension so they do not show up file type as=
text document instead just a type as file=0A=0A=09* the date is not being =
appended to the name=0AMy code below is in the properties file in the Proje=
ct default package folder as Mark Eggers suggested. I am not sure which pro=
perty to modify to get the .log extension and the date appended.=0A=0A=0A=
=0A#log4j.properties File=0A=0Alog4j.rootLogger=3DINFO, CATALINA, CONSOLE=
=0A=0A#Tweet Tag Processor=0Alog4j.logger.org.tweettagprocessorpackage=3DIN=
FO, R=0A=0A# Define all the appenders=0A=0A# Configuration for a rolling lo=
g file.=0Alog4j.appender.R=3Dorg.apache.log4j.DailyRollingFileAppender=0A# =
Edit the next line to point to your logs directory.=0A# The last part of th=
e name is the log file name.=0Alog4j.appender.R.file=3D${catalina.base}/log=
s/tagprocessor.=0Alog4j.appender.R.encoding=3DUTF-8=0A# Roll-over the log o=
nce per day=0Alog4j.appender.R.DatePattern=3D'.'yyyy-MM-dd'.log'=0A# Print =
the date in ISO 8601 format=0Alog4j.appender.R.layout=3Dorg.apache.log4j.Pa=
tternLayout=0Alog4j.appender.R.layout.ConversionPattern=3D%d [%t] %-5p %c -=
%m%n=0Alog4j.appender.R.append=3Dtrue=0A=0Alog4j.appender.CATALINA=3Dorg.a=
pache.log4j.DailyRollingFileAppender=0Alog4j.appender.CATALINA.file=3D${cat=
alina.base}/logs/catalina-my.=0Alog4j.appender.CATALINA.encoding=3DUTF-8=0A=
# Roll-over the log once per day=0Alog4j.appender.CATALINA.DatePattern=3D'.=
'yyyy-MM-dd'.log'=0Alog4j.appender.CATALINA.layout=3Dorg.apache.log4j.Patte=
rnLayout=0Alog4j.appender.CATALINA.layout.ConversionPattern =3D %d [%t] %-5=
p %c - %m%n=0Alog4j.appender.CATALINA.append=3Dtrue=0A=0Alog4j.appender.LOC=
ALHOST=3Dorg.apache.log4j.DailyRollingFileAppender=0Alog4j.appender.LOCALHO=
ST.file=3D${catalina.base}/logs/localhost-my.=0Alog4j.appender.LOCALHOST.en=
coding=3DUTF-8=0Alog4j.appender.LOCALHOST.DatePattern=3D'.'yyyy-MM-dd'.log'=
=0Alog4j.appender.LOCALHOSTlayout=3Dorg.apache.log4j.PatternLayout=0Alog4j.=
appender.LOCALHOST.layout.ConversionPattern =3D %d [%t] %-5p %c - %m%n=0Alo=
g4j.appender.LOCALHOST.append=3Dtrue=0A=0Alog4j.appender.MANAGER=3Dorg.apac=
he.log4j.DailyRollingFileAppender=0Alog4j.appender.MANAGER.file=3D${catalin=
a.base}/logs/manager-my.=0Alog4j.appender.MANAGER.encoding=3DUTF-8=0Alog4j.=
appender.MANAGER.DatePattern=3D'.'yyyy-MM-dd'.log'=0Alog4j.appender.MANAGER=
.layout=3Dorg.apache.log4j.PatternLayout=0Alog4j.appender.MANAGER.layout.Co=
nversionPattern =3D %d [%t] %-5p %c - %m%n=0Alog4j.appender.MANAGER.append=
=3Dtrue=0A=0Alog4j.appender.HOST-MANAGER=3Dorg.apache.log4j.DailyRollingFil=
eAppender=0Alog4j.appender.HOST-MANAGER.file=3D${catalina.base}/logs/host-m=
anager-my.=0Alog4j.appender.HOST-MANAGER.encoding=3DUTF-8=0Alog4j.appender.=
HOST-MANAGER.DatePattern=3D'.'yyyy-MM-dd'.log'=0Alog4j.appender.HOST-MANAGE=
R.layout=3Dorg.apache.log4j.PatternLayout=0Alog4j.appender.HOST-MANAGER.lay=
out.ConversionPattern =3D %d [%t] %-5p %c - %m%n=0Alog4j.appender.HOST-MANA=
GER.append=3Dtrue=0A=0Alog4j.appender.CONSOLE=3Dorg.apache.log4j.ConsoleApp=
ender=0Alog4j.appender.CONSOLE.encoding=3DUTF-8=0Alog4j.appender.CONSOLE.la=
yout=3Dorg.apache.log4j.PatternLayout=0Alog4j.appender.CONSOLE.layout.Conve=
rsionPattern =3D %d [%t] %-5p %c - %m%n=0A=0A# Configure which loggers log =
to which appenders=0Alog4j.logger.org.apache.catalina.core.ContainerBase.[C=
atalina].[localhost]=3DINFO, LOCALHOST=0Alog4j.logger.org.apache.catalina.c=
ore.ContainerBase.[Catalina].[localhost].[/manager]=3D\=0A=A0 INFO, MANAGER=
=0Alog4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhos=
t].[/host-manager]=3D\=0A=A0 INFO, HOST-MANAGER=0A=0A=A0 =0A=0A=0A=0ACheers=
,=0AA Df=0A=0AFrom: Mark Eggers <its_toasted@yahoo.com>=0A=0ATo: Tomcat Use=
rs List <users@tomcat.apache.org>; A Df <abbey_dragonforest@yahoo.com>=0A>S=
ent: Friday, 29 July 2011, 19:04=0A>Subject: Re: Missing files for Apache a=
nd Log4J=0A>=0A>> From: A Df <abbey_dragonforest@yahoo.com>=0A>=0A>>
Dear A=
ll:=0A>> =0A>> I have created a Java web application and I want to have log=
ging to ensure that =0A>> the appropriate messages are stored in log files =
instead of to standard output. =0A>> I found a link at http://tomcat.apache=
.org/tomcat-6.0-doc/logging.html and was =0A>> following the instruction bu=
t I am unclear for these steps. My details are:=0A>> =0A>> =A0=A0=A0 * Apac=
he Tomcat 6.0.26=0A>> =A0=A0=A0 * Log 4j 1.2.16=0A>> =0A>> The instructions=
specify=0A>> =0A>> =A0=A0=A0 * Build or download the additional logging co=
mponents.=0A>> I am new to logging, so I am not sure what other extra are n=
eeded!=0A>> =0A>> =A0=A0=A0 * Replace $CATALINA_HOME/bin/tomcat-juli.jar wi=
th =0A>> output/extras/tomcat-juli.jar.=0A>> Does this mean that I move the=
jar from that location and create the folders to =0A>> put it in another l=
ocation to have :C:\Program Files\Apache Software =0A>> Foundation\Apache T=
omcat 6.0.26\output\extras?=0A>> =0A>> =0A>> =A0=A0=A0 * Place output/extra=
s/tomcat-juli-adapters.jar in $CATALINA_HOME/lib.I =0A>> cannot find the ja=
r file in the Log4J download or Apache files so where is it =0A>> located?=
=0A>> =0A>> Is Log4J the best logging to use with a Java web app? Do you ha=
ve any =0A>> suggestions?=0A>> =0A>> Thanks for your help,=0A>> A
Df=0A>>=
=0A>=0A>Logging for a particular web application is different (or can be) t=
han=0A>logging for Tomcat.=0A>=0A>What I normally do is leave Tomcat loggin=
g as is (or modify it for=0A>better cluster logging), and use logging-commo=
ns / log4j for web=0A>applications.=0A>=0A>Using logging-commons / log4j fo=
r a particular web application is=0A>pretty straightforward.=0A>=0A>1. Incl=
ude commons-logging-1.1.1.jar and log4j-1.2.15.jar in your=0A>=A0 =A0applic=
ation's WEB-INF/lib folder=0A>=0A>2. Create a logging.properties file or a =
log4j.xml file and place it=0A>=A0 =A0in the application's WEB-INF/class fo=
lder=0A>=0A>3. Add logging instructions to your classes=0A>=0A>By default l=
ogging-commons will use log4j, so no other special=0A>configuration is nece=
ssary.=0A>=0A>It's nice to use logging-commons, since this makes it easier =
to switch=0A>out logging from log4j to another package should you choose to=
.=0A>=0A>Since I know you use NetBeans, the following is NetBeans-specific:=
=0A>=0A>* Add the jars=0A>=0A>There are several ways to include third party=
jars in your=0A>project. The quick and dirty way is to do the following.=
=0A>=0A>1. Create a folder (call it libs) in your project=0A>2. Copy the ja=
rs into that folder=0A>3. Right-mouse click on the Libraries node in your p=
roject=0A>4. Select Add Jar/Folder=0A>5. Browse to where you copied the jar=
files=0A>6. Add them=0A>=0A>By default, those jars will now be packaged up=
in the WAR file and=0A>included in your application's WEB-INF/lib folder.=
=0A>=0A>For individual development this is probably OK. For a more robust=
=0A>environment, it might be nice to add the jars to version control, creat=
e a=0A>NetBeans library with the two jars, or even use Maven or Ivy to mana=
ge=0A>dependencies.=0A>=0A>* Create a properties file=0A>=0A>I actually pre=
fer using the xml file, but there are several open=0A>issues with using cus=
tom DTDs or schemas when editing XML files with=0A>NetBeans. So, a properti=
es file is easier to use.=0A>=0A>1. Navigate to your Source Packages -> <de=
fault package> node=0A>2. Right-mouse click and select New -> Other=0A>3. F=
ind Properties File in the dialog box (it's under Other)=0A>4. Call it log4=
j (NetBeans adds the .properties)=0A>5. Edit away=0A>=0A>NetBeans will pack=
age up the file in WEB-INF/classes of your=0A>application, where it can be =
found by the log4j classes.=0A>=0A>Here's a quick example of a log4j.proper=
ties file:=0A>=0A>### direct messages to file simple.log ###=0A>log4j.appen=
der.file=3Dorg.apache.log4j.FileAppender=0A>log4j.appender.file.File=3D${ca=
talina.base}/logs/simple.log=0A>log4j.appender.file.layout=3Dorg.apache.log=
4j.PatternLayout=0A>log4j.appender.file.layout.ConversionPattern=3D%d{ABSOL=
UTE} %5p %c{1}:%L - %m%n=0A>=0A>### default logging level=0A>log4j.rootLogg=
er=3Dwarn,file=0A>=0A>### for the simple application=0A>log4j.logger.simple=
.controller=3Dinfo,file=0A>=0A>Read the documentation that comes with log4j=
on how to create=0A>log4j.properties files for more information. For examp=
le, change the=0A>log4j.logger definitions to fit your package names and de=
sired level=0A>of logging.=0A>=0A>One thing of interest to note here is whe=
re the log gets written. I've=0A>used ${catalina.base}/logs as the director=
y for the log file. This=0A>will write simple.log in the same logging direc=
tory that Tomcat=0A>uses. This may or may not be what you want. Change the =
location as=0A>appropriate.=0A>=0A>=0A>. . . . just my two cents.=0A>/mde/=
=0A>=0A>=0A>---------------------------------------------------------------=
------=0A>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org=0A>Fo=
r additional commands, e-mail: users-help@tomcat.apache.org=0A>=0A>=0A>=0A>=
=0A>
|