This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Need helping configuring Log4j configuration file to mirror current setup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Need helping configuring Log4j configuration file to mirror current setup" Watch "Need helping configuring Log4j configuration file to mirror current setup" New topic
Author

Need helping configuring Log4j configuration file to mirror current setup

Bruce Kent
Greenhorn

Joined: Apr 13, 2011
Posts: 2
Hello,

I am attempting to configure Log4j in Apache Tomcat 5.5, replacing the previous logging system, which I believe is JULI. I wish to mirror the current setup in Log4j, but add the ability to split the log files dynamically if they reach a certain file size in the format of logfilename_YYYY-MM-DD_Number.log, i.e. Catalina_2011-04-18_1.log, Catalina_2011-04-18_2.log.

Let me stop and say I believe I have installed and configured Log4j correctly, placing the files in the proper directories. It's simply a matter of understanding how to configure the log4j.properties file.

For example, this worked:



But the next one didn't...
As a test, for I want to use baby steps to minimize confusion for myself and for others reading this post, here is the contents of the log4j.properties file, currently:



Unfortunately, nothing happens and I don't know why. I thought DailyRollingfileAppender will allow me to split a 30 KB Catalina log file into 10 3 KB files in the format of Catalina_YYYY-MM-DD_Number.log. The whole idea is to limit the file size and include the date and the number of the file, if it's too big to put into one file, all in the file name.

I would appreciate any help.

Thank you.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17155
    
  27

I believe that you have to use the XML version of the log4j config file (log4j.xml) to properly configure the rolling file appender. I forget exactly why, but I don't think it's supported using log4j.properties.


An IDE is no substitute for an Intelligent Developer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need helping configuring Log4j configuration file to mirror current setup
 
It's not a secret anymore!