tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From A Df <>
Subject Re: Missing files for Apache and Log4J
Date Wed, 03 Aug 2011 10:17:08 GMT
Hello Mates:

I 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 daily file. I also wanted to have control over the usual
logs that Tomcat produced so I combined your instructions with those from this other website
at to get the content for
the properties file. However, the problems are:
	* the log files do not have the .log extension so they do not show up file type as text document
instead just a type as file

	* the date is not being appended to the name
My code below is in the properties file in the Project default package folder as Mark Eggers
suggested. I am not sure which property to modify to get the .log extension and the date appended. File

log4j.rootLogger=INFO, CATALINA, CONSOLE

#Tweet Tag Processor, R

# Define all the appenders

# Configuration for a rolling log file.
# Edit the next line to point to your logs directory.
# The last part of the name is the log file name.
# Roll-over the log once per day
# Print the date in ISO 8601 format
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

# Roll-over the log once per day
log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c - %m%n

log4j.appender.LOCALHOST.layout.ConversionPattern = %d [%t] %-5p %c - %m%n

log4j.appender.MANAGER.layout.ConversionPattern = %d [%t] %-5p %c - %m%n

log4j.appender.HOST-MANAGER.layout.ConversionPattern = %d [%t] %-5p %c - %m%n

log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c - %m%n

# Configure which loggers log to which appenders[Catalina].[localhost]=INFO, LOCALHOST[Catalina].[localhost].[/manager]=\
  INFO, MANAGER[Catalina].[localhost].[/host-manager]=\


A Df

From: Mark Eggers <>

To: Tomcat Users List <>; A Df <>
>Sent: Friday, 29 July 2011, 19:04
>Subject: Re: Missing files for Apache and Log4J
>> From: A Df <>
>> Dear All:
>> I have created a Java web application and I want to have logging to ensure that 
>> the appropriate messages are stored in log files instead of to standard output. 
>> I found a link at and was 
>> following the instruction but I am unclear for these steps. My details are:
>>     * Apache Tomcat 6.0.26
>>     * Log 4j 1.2.16
>> The instructions specify
>>     * Build or download the additional logging components.
>> I am new to logging, so I am not sure what other extra are needed!
>>     * Replace $CATALINA_HOME/bin/tomcat-juli.jar with 
>> output/extras/tomcat-juli.jar.
>> Does this mean that I move the jar from that location and create the folders to 
>> put it in another location to have :C:\Program Files\Apache Software 
>> Foundation\Apache Tomcat 6.0.26\output\extras?
>>     * Place output/extras/tomcat-juli-adapters.jar in $CATALINA_HOME/lib.I 
>> cannot find the jar file in the Log4J download or Apache files so where is it 
>> located?
>> Is Log4J the best logging to use with a Java web app? Do you have any 
>> suggestions?
>> Thanks for your help,
>> A Df
>Logging for a particular web application is different (or can be) than
>logging for Tomcat.
>What I normally do is leave Tomcat logging as is (or modify it for
>better cluster logging), and use logging-commons / log4j for web
>Using logging-commons / log4j for a particular web application is
>pretty straightforward.
>1. Include commons-logging-1.1.1.jar and log4j-1.2.15.jar in your
>   application's WEB-INF/lib folder
>2. Create a file or a log4j.xml file and place it
>   in the application's WEB-INF/class folder
>3. Add logging instructions to your classes
>By default logging-commons will use log4j, so no other special
>configuration is necessary.
>It's nice to use logging-commons, since this makes it easier to switch
>out logging from log4j to another package should you choose to.
>Since I know you use NetBeans, the following is NetBeans-specific:
>* Add the jars
>There are several ways to include third party jars in your
>project. The quick and dirty way is to do the following.
>1. Create a folder (call it libs) in your project
>2. Copy the jars into that folder
>3. Right-mouse click on the Libraries node in your project
>4. Select Add Jar/Folder
>5. Browse to where you copied the jar files
>6. Add them
>By default, those jars will now be packaged up in the WAR file and
>included in your application's WEB-INF/lib folder.
>For individual development this is probably OK. For a more robust
>environment, it might be nice to add the jars to version control, create a
>NetBeans library with the two jars, or even use Maven or Ivy to manage
>* Create a properties file
>I actually prefer using the xml file, but there are several open
>issues with using custom DTDs or schemas when editing XML files with
>NetBeans. So, a properties file is easier to use.
>1. Navigate to your Source Packages -> <default package> node
>2. Right-mouse click and select New -> Other
>3. Find Properties File in the dialog box (it's under Other)
>4. Call it log4j (NetBeans adds the .properties)
>5. Edit away
>NetBeans will package up the file in WEB-INF/classes of your
>application, where it can be found by the log4j classes.
>Here's a quick example of a file:
>### direct messages to file simple.log ###
>log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
>### default logging level
>### for the simple application
>Read the documentation that comes with log4j on how to create
> files for more information. For example, change the
>log4j.logger definitions to fit your package names and desired level
>of logging.
>One thing of interest to note here is where the log gets written. I've
>used ${catalina.base}/logs as the directory for the log file. This
>will write simple.log in the same logging directory that Tomcat
>uses. This may or may not be what you want. Change the location as
>. . . . just my two cents.
>To unsubscribe, e-mail:
>For additional commands, e-mail:
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message