This content has been marked as final.
Show 6 replies
-
1. Re: Log Size
jaikiran Oct 12, 2006 5:55 AM (in response to stez192)Are you using log4j? If yes, then log4j allows you to configure the log file sizes so that once a specified size is reached the file is rolled over and a new file is created. Maybe this might help:
http://logging.apache.org/log4j/docs/manual.html -
2. Re: Log Size
stez192 Oct 12, 2006 6:05 AM (in response to stez192)Thanks, I am using log4j.xml
can you please advise me how to insert this in the XML structure?
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1 -
3. Re: Log Size
jaikiran Oct 12, 2006 6:22 AM (in response to stez192)Here's the xml configuration:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <!-- ===================================================================== --> <!-- --> <!-- Log4j Configuration --> <!-- --> <!-- ===================================================================== --> <!-- $Id: log4j.xml,v 1.13.2.8 2003/09/23 14:16:27 slaboure Exp $ --> <!-- | For more configuration infromation and examples see the Jakarta Log4j | owebsite: http://jakarta.apache.org/log4j --> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <!-- ================================= --> <!-- Preserve messages in a local file --> <!-- ================================= --> <!-- A size based rolling appender --> <appender name="FILE" class="org.apache.log4j.FileAppender"> <param name="File" value="D:/log/myLog.log"/> <param name="Append" value="false"/> <param name="MaxFileSize" value="50MB"/> <param name="MaxBackupIndex" value="100"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{ISO8601} [%X{TAPUSERNAME}] %-5p [%c] %m%n"/> </layout> </appender> <!-- ============================== --> <!-- Append messages to the console --> <!-- ============================== --> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> <param name="Threshold" value="INFO"/> <layout class="org.apache.log4j.PatternLayout"> <!-- The default pattern: Date Priority [Category] Message\n --> <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{1}] %m%n"/> </layout> </appender> <!-- ================ --> <!-- Limit categories --> <!-- ================ --> <category name="org.myapp"> <priority value="DEBUG" /> <appender-ref ref="FILE"/> </category> <!-- ======================= --> <!-- Setup the Root category --> <!-- ======================= --> <root> <appender-ref ref="CONSOLE"/> </root> </log4j:configuration>
You can set the "MaxFileSize" and "MaxBackupIndex" and any other attribute values depending on your needs -
4. Re: Log Size
stez192 Oct 12, 2006 6:56 AM (in response to stez192)OK, thanks a lot, this should work
-
5. Re: Log Size
jaikiran Oct 12, 2006 7:12 AM (in response to stez192)Just a small change. There was a mistake in the previous post:
<appender name="FILE" class="org.apache.log4j.FileAppender">
This should have been:<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
-
6. Re: Log Size
jaikiran Oct 12, 2006 7:16 AM (in response to stez192)Uuuhh... some of the contents got eaten up in my previous post. Here's the final one.
Change<appender name="FILE" class="org.apache.log4j.FileAppender">
to<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
Apologies for all the mess.