You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by pradeep <pr...@jgsullivan.com> on 2001/08/22 20:29:39 UTC

how tdo u set the daily rolling file appender in xml config file

hi guy i need to have a rollover file created at the end of each day.im 
using DomConfigurator with xmlconfig file
could u suggest me how to achieve that .i know that i need to use 
DailyRollingFileAppender
thx
pradeep.
here is my java code:
       strXmlfile=ResourceManager.getResource(LOG_FILE_LOCATION, null);
       log4j=Category.getInstance(OemsSystemLog.class.getName());
       DOMConfigurator.configure(strXmlfile);

here is my xmlconfig file:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This file is the configuartion files for all logging activities -->
<!-- This file prints int  a file called oemssys.log-->
<!-- To print the o/p to console comment the section  'FILE  COMMENTS START 
HERE'
     AND uncomment 'CONSOLE'.The default is file o/p.-->
<!-- SEARCH FOR 'DEBUG' and follow the instruction to disable log message-->
  <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

  <!--CONSOLE-->
<!-- <appender name="systemlog" class="org.apache.log4j.ConsoleAppender">-->

  <!--FILE  COMMENTS START HERE-->
<appender name="systemlog" class="org.apache.log4j.FileAppender">-->
  <param name="File" value="C:/projects/oemsv2/logout/oemsys.log" />
<!--FILE END COMMENTS HERE-->
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} | 
%C{1} | %-5p | - %m\n" />
   </layout>
  </appender>


  <category name="com.oems.util.OemsSystemLog">
  <!--DEBUG change the value to fatal if u need to disable log messages -->
   <priority value="info" />
   </category>
<root>
<priority value="info"  />
   <appender-ref ref="systemlog" />
   </root>

   </log4j:configuration>


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: how tdo u set the daily rolling file appender in xml config file

Posted by Don Taylor <do...@yahoo.com>.
Try

<!--FILE  COMMENTS START HERE-->
<appender name="systemlog"
class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="C:/projects/oemsv2/logout/oemsys.log" />
<param name="datePattern" value="'.'yyyy-MM-dd" />

All you needed to do was specify the DailyRollingFileAppender and set
the datePattern property to when you want the rollover. This particular
datePattern will rollover daily like you want.

-- Don

--- pradeep <pr...@jgsullivan.com> wrote:
> hi guy i need to have a rollover file created at the end of each
> day.im 
> using DomConfigurator with xmlconfig file
> could u suggest me how to achieve that .i know that i need to use 
> DailyRollingFileAppender
> thx
> pradeep.
> here is my java code:
>        strXmlfile=ResourceManager.getResource(LOG_FILE_LOCATION,
> null);
>        log4j=Category.getInstance(OemsSystemLog.class.getName());
>        DOMConfigurator.configure(strXmlfile);
> 
> here is my xmlconfig file:
> <?xml version="1.0" encoding="UTF-8" ?>
> <!-- This file is the configuartion files for all logging activities
> -->
> <!-- This file prints int  a file called oemssys.log-->
> <!-- To print the o/p to console comment the section  'FILE  COMMENTS
> START 
> HERE'
>      AND uncomment 'CONSOLE'.The default is file o/p.-->
> <!-- SEARCH FOR 'DEBUG' and follow the instruction to disable log
> message-->
>   <log4j:configuration
> xmlns:log4j="http://jakarta.apache.org/log4j/">
> 
>   <!--CONSOLE-->
> <!-- <appender name="systemlog"
> class="org.apache.log4j.ConsoleAppender">-->
> 
>   <!--FILE  COMMENTS START HERE-->
> <appender name="systemlog" class="org.apache.log4j.FileAppender">-->
>   <param name="File" value="C:/projects/oemsv2/logout/oemsys.log" />
> <!--FILE END COMMENTS HERE-->
>     <layout class="org.apache.log4j.PatternLayout">
>       <param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss}
> | 
> %C{1} | %-5p | - %m\n" />
>    </layout>
>   </appender>
> 
> 
>   <category name="com.oems.util.OemsSystemLog">
>   <!--DEBUG change the value to fatal if u need to disable log
> messages -->
>    <priority value="info" />
>    </category>
> <root>
> <priority value="info"  />
>    <appender-ref ref="systemlog" />
>    </root>
> 
>    </log4j:configuration>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org