TomcatExpert

How to configure log rotation in Apache Tomcat 5.5 and 6.0 using the Juli logging package

posted by SpringSource on March 18, 2010 11:46 PM

How to enable file rotation to periodically purge older log files and clear space using the default juli internal logging for Apache Tomcat.

By default, Apache Tomcat dies its internal logging through juli. The quantity of information stored in the log files on any server can quickly grow to be quite large. For instance, the access log file typically grows 1 MB or more per 10,000 requests. Therefore, it may be necessary to periodically rotate the log files by moving the files or deleting the existing logs to free up space on the server and allow for more efficient searching through logs. This cannot be done while the server is running, because Apache Tomcat will continue writing to the old log file as long as it holds the file open.

 To achieve this, in the logging.properties, add: 

.handlers = 1catalina.java.util.logging.FileHandler 
.level=FINE 
 
1catalina.java.util.logging.FileHandler.level = FINE 
1catalina.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/${catalina.appserver.instance}.%g.log 
1catalina.java.util.logging.FileHandler.limit = 2000000 
1catalina.java.util.logging.FileHandler.count = 5 
1catalina.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

where 1catalina.java.util.logging.FileHandler would instantiate the FileHandler that comes with JDK.

Since java.util.logging.FileHandler does not have .prefix or .directory, .prefix and .directory needs to be set in the catalina package:

1catalina.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/catalina.%g.log 

NOTE: The names have to be consistent everywhere, including in the handlers and .handlers references.

For further details, the JDK filehandler is documented at: http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/FileHandler.html

For more than 10 years, SpringSource employees have been supporting Apache technologies, with unparalleled experience and commitment to the Apache Software Foundation. More than 400 of the Fortune 500 count on SpringSource to support their mission-critical business applications. Leaders of the Apache Software Foundation, including Board Members, work at SpringSource and dedicate a significant amount of time further developing the Apache Tomcat open source project. Over the last 2 years, 95% of the issues fixed in the Apache Tomcat project were fixed by SpringSource engineers. For more information on how SpringSource can help your enterprise, see the SpringSource website, or call 800/444-1935.

Comments

The "<handlers></handlers>"

The "<handlers></handlers>" seems confusing. Perhaps using the normal comment syntax is more appropriate:

####
# Define custom logging handlers
####

Thanks

Thanks for spotting that. Looks like a copy/paste error. I've fixed the logging.properties extract by removing those tags.

This is just another reason

This is just another reason why I like your work the best. Man, your work is sublime! You are always providing us with great, helpful informative articles. It's always a joy to read your articles. I hope you'll keep this good work going on! payday loans for bad credit in canada

obat stroke paling manjur

Obat Alami Ambeien Paling Tepat Untuk Diminum
Cara Mencegah Menggunakan amazon Plus Alami Obat Tradisional Wasir. Cara penyembuhan terbaik guna pencegahan ambeien dengan menjaga tinja tetap elastis agar bisa keluar dengan gampang, sehingga mengurangi tekanan & tegangan pada anus, selesaikan secepat mungkin setelah ada rangsangan buang air besar obat ambeien.

Stroke Dipulihkan, Badanpun fit berkat Obat Tradisional amazon
Jus Kulit Manggis Obat Alami Stroke dipercaya sudah banyak mengobati pasien storke yang mungkin sudah puluhan tahun dideritanya. Banyak cara lainnya untuk terhindar dari serangan penyakit stroke selain menggunakan Jus Kulit Manggis Obat Stroke, yaitu kegemukan, kolesterol tinggi, makanan kecil, serta mulailah lebih banyak makan buah-buahan, padi-padian dan makan makanan berserat tinggi lainnya serta ikan obat stroke paling manjur.

Solusi terbaru dan pertama di Asia Tenggara yang merupakan salah satu karya asli anak bangsa, yaitu obat Obat Tradisional Alami Penyakit Gondok “Jus Kulit Manggis”.
amazon Plus yaitu jawaban yang paling aman untuk mengatasi penyakit gondok, rasanya yang lezat & terjamin selama fase pengobatan bebas ada efek samping obat gondokan.

sl786982

Very true and inspiring article. I strongly believe all your points. I also learned a lot from your post. Cheers and thank you for the clear path. Chinese medicine clinic

sl786982

sl786982

Really a great addition. I have read this marvelous post. Thanks for sharing information about it. I really like that. Clinic online

sl786982

A debt of gratitude is in

A debt of gratitude is in order for the blog entry mate! Keep them coming... hotel escort amsterdam

I am happy to find this post

I am happy to find this post Very useful for me, as it contains lot of information. I Always prefer to read The Quality and glad I found this thing in you post. Thanks
new futura floor plan

I'm glad to see the great

I'm glad to see the great detail here!.
wedding outfits

Nice post! This is a very

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post.
billiga sminkborstar online med fri frakt

I think this is an

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.new futura 4 bedroom

dani

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!
click this site

dani

Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us.
container shipping

DANi

I really like your take on the issue. I now have a clear idea on what this matter is all about..
DealerSocket Login

Thanks for sharing this

Thanks for sharing this quality information with us. I really enjoyed reading. Will surely going to share this URL with my friends.
Mesothelioma Cancer

DANi

That is the excellent mindset, nonetheless is just not help to make every sence whatsoever preaching about that mather. Virtually any method many thanks in addition to i had endeavor to promote your own article in to delicius nevertheless it is apparently a dilemma using your information sites can you please recheck the idea. thanks once more.
swann morton

ads

Thanks for your post. I’ve been thinking about writing a very comparable post over the last couple of weeks, I’ll probably keep it short and sweet and link to this instead if thats cool. Thanks.
Lelio Vieira Carneiro Junior

I love the way you write and

I love the way you write and share your niche! Very interesting and different! Keep it coming!
prompteur ipad

I was surfing net and

I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information.
shopping mall

DANI

Good article, but it would be better if in future you can share more about this subject. Keep posting.

It’s appropriate time to make

It’s appropriate time to make some plans for the future and it is time to be happy. I have read this post and if I could I wish to suggest you few interesting things or advice. Perhaps you could write next articles referring to this article. I desire to read even more things about it!
go here

I have read a few of the

I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favorites blog site list and will be checking back soon. Please check out my site as well and let me know what you think.
find here

DANI

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.
designer smiles dentistry

DANI

thanks for this usefull article, waiting for this article like this again.
Veterans Suicide

Superbly written article, if

Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place..
Cannaline

Thanks for taking the time to

Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us.
click this site

ads

Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!.
check this

I am happy to find this post

I am happy to find this post very useful for me, as it contains lot of information. I always prefer to read the quality content and this thing I found in you post. Thanks for sharing.
click here

I am very much pleased with

I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article.
shopping online

Nice to read your article! I

Nice to read your article! I am looking forward to sharing your adventures and experiences.
Nice to read your article! I am looking forward to sharing your adventures and experiences.
T-Mobile® and Metro PCS® authorized dealer

Thanks for your insight for

Thanks for your insight for your fantastic posting. I’m glad I have taken the time to see this.
Geldbörse nähen

This is a great article

This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post.
melatonina preço

Sa

Your article has piqued a lot of positive interest. I can see why since you have done such a good job of making it interesting.
Posters

I wanted to thank you for

I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post.
go here

I am hoping the same best

I am hoping the same best effort from you in the future as well. In fact your creative writing skills has inspired me.
Pay Monthly Phones

This is very educational

This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post.!
painless wax beans

Thanks for the post and great

Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..
airshou

Hi! Thanks for the great

Hi! Thanks for the great information you have provided! You have touched on crucuial points!
Baseline Prestige

Sa

I gotta favorite this website it seems very helpful .
property for sale

Hello, I am always on the

Hello, I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future! www.vicsolar.com.au

Time based log file rotation

Using JULI how would you configure log file rotation on daily or hourly basis.

Limiting catalina.out

Hi ,

I changed the logging.properties as mentioned in the post.
I believe it is working fine.
But catalina.out seems growing to unbelievable size.
How to limit and rotate it?
My logging.properties is as follows :

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

handlers = 1catalina.java.util.logging.FileHandler, 2localhost.java.util.logging.FileHandler, 3manager.java.util.logging.FileHandler, 4host-manager.java.util.logging.FileHandler, java.util.logging.ConsoleHandler

.handlers = 1catalina.java.util.logging.FileHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.java.util.logging.FileHandler.level = FINE
1catalina.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/catalina.%g.log
1catalina.java.util.logging.FileHandler.limit = 2000
1catalina.java.util.logging.FileHandler.count = 2
1catalina.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

2localhost.java.util.logging.FileHandler.level = FINE
2localhost.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/localhost.%g.log
2localhost.java.util.logging.FileHandler.limit = 2000
2localhost.java.util.logging.FileHandler.count = 2
2localhost.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

3manager.java.util.logging.FileHandler.level = FINE
3manager.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/manager.%g.log
3manager.java.util.logging.FileHandler.limit = 2000
3manager.java.util.logging.FileHandler.count = 2
3manager.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

4host-manager.java.util.logging.FileHandler.level = FINE
4host-manager.java.util.logging.FileHandler.pattern = ${catalina.base}/logs/host-manager.%g.log
4host-manager.java.util.logging.FileHandler.limit = 2000
4host-manager.java.util.logging.FileHandler.count = 2
4host-manager.java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.java.util.logging.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.java.util.logging.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.java.util.logging.FileHandler

# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE

# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = FINE

and I ve done a small change to catalina.sh as per the blog here: http://www.ginnokagi.com/2012/08/tomcat_tuning_in_practice.html

What am I doing wrong here..?
When i comment out touch in line 372 as
#touch "$CATALINA_OUT"
catalina.out is not getting written at all.

Any ideas..
Thanks in advance,
Mohan
mohan@yatech.in

<a href="http://goo.gl/PbacCN">Lowongan</a>

Lowongan
HIT Obat Nyamuk
Nissan X-Trail Mobil SUV Tangguh dan Sporty Terbaik
Nissan X-Trail Mobil SUV Tangguh dan Sporty Terbaik

Cara Terbaru 

This is a savvy blog. I would

This is a savvy blog. I would not joke about this. You have such a great amount of learning about this issue, thus much enthusiasm. You additionally know how to make individuals rally behind it, clearly from the reactions. NBA 2K18 Neighborhood

GAME HACK

8 ball pool hack android At this point you'll find out what is important, it all gives a url to the appealing page: free gems clash of clans

By standard, Apache Tomcat

By standard, Apache Tomcat passes away its inner signing through juli. The quantity of information held in the log information on any server can quickly grow to be quite large. For instance, the access log computer file typically develops 1 MB or more per 10,000 demands. Therefore, it may be necessary to regularly move the log information by moving the information or removing the current records to free up space on the server and allow for more efficient searching through records. This cannot be done while the server is running, because Apache Tomcat will continue writing to the old log computer file as long as it keeps the computer file open homepage.

By conventional, Apache

By conventional, Apache Tomcat goes away its inner selecting through juli. The quantity of information kept in the log information regarding any server can quickly turn into quite large. For example Homepage, the access log computer computer file generally generates 1 MB or more per 10,000 specifications.

By conventional, Apache

By conventional, Apache Tomcat passes away its inner selecting through juli. The quality of information kept in the log details on any server can quickly turn into quite large. For example pictures of funny dogs, the access log pc computer information file generally generates 1 MB or more per 10,000 specifications. Therefore, it may be necessary to continually move the log details by shifting the facts or taking out the current details to free up space on the server and allow for more effective looking through details.

By conventional, Apache

By conventional, Apache Tomcat passes away its inner choosing through juli. The quality of information kept in the log information regarding any server can quickly turn into quite large. For example pictures of insane animals, the access log pc pc information pc computer file generally generates 1 MB or more per 10,000 specifications. Therefore, it may be necessary to regularly go to website, move the log information by moving everything or taking out the current information to free up space on the server and allow for more effective looking through information.

By conventional, Apache

By conventional, Apache Tomcat goes away its inner choosing through juli. The quality of information kept in the log information on any server can quickly become quite huge. For example pictures of insane animals, the availability log pc pc information pc pc computer computer file usually generates 1 MB or more per had me going, 10,000 specifications. Therefore, it may be necessary to continually go to website, move the log information by moving everything or taking out the existing information to free up area on the server and allow for more valuable looking through information.

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.