File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes cnfiguring accesslogvalve to rotate log every 2 hours Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "cnfiguring accesslogvalve to rotate log every 2 hours" Watch "cnfiguring accesslogvalve to rotate log every 2 hours" New topic
Author

cnfiguring accesslogvalve to rotate log every 2 hours

conrad Johnston
Greenhorn

Joined: Jan 19, 2011
Posts: 5

Hi,

I am setting up some web logging and need to be able to configure a non standard log rotation period.

I understand from the Apache foundations doc that adding fileDateFormat="yyyy-MM-dd.HH" will force the log to be rotated every hour.

but it doesn't really give you any more clues than that. Has anyone come across this before?

Cheers,

C.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

Welcome to the JavaRanch, Conrad!

I'm not sure exactly what you mean. What most people think of as Tomcat's main "log" file (catalina.out) isn't even a proper log. It's just the redirected stdout/stderr from the JVM that Tomcat is running in. And, incidentally, because it's not a true logfile, it's not recommended for webapps to write to stdout/stderr.

Are you referring to one of the other logs such as the localhost log or the log produced optionally when the request-tracking valve is enabled (access log)?


Customer surveys are for companies who didn't pay proper attention to begin with.
conrad Johnston
Greenhorn

Joined: Jan 19, 2011
Posts: 5

Hi,

sorry, i was a little too vague!

I am configuring web referrer logging. The current configuration I have is as follows:


The Apache Foundations documentation for Tomcat state the following for the attribute fileDateFormat

"Allows a customized date format in the access log file name. The date format also decides how often the file is rotated. If you wish to rotate every hour, then set this value to: yyyy-MM-dd.HH"

This rotates that log every hour with the naming format as given in my config above, but i really need it to rotate every 2 hours.

My current work around is to post process the logs and concatenate two of them together. But it would be nicer if I could get Tomcat to do this step for me!

Cheers,

C.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

Actually, unless you edited your topic title, I was suffering from my usual early-morning blindness. At any rate, it says very specifically "Access Log Valve" now.

I can't think of any way to specify a pattern using their rules that would be good for every 2 or 3 or whatever hours. You can always check to see if there's a crontab-like pattern option attribute. Otherwise, your best bet is probably to yank a copy of the accesslog valve code and create a customized copy.
conrad Johnston
Greenhorn

Joined: Jan 19, 2011
Posts: 5

cheers tim,

I think i will go with my post processing option and concatenate the logs. I don't want to create version dependencies for those that follow.

Thanks very much for your assistence though.

C.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: cnfiguring accesslogvalve to rotate log every 2 hours
 
Similar Threads
Log4j configuration question
How create a new log for every run?
How much logging?
log4j DailyRollingFileAppender
What is Java Reflection