Results 1 to 3 of 3
  1. #1
    javastuden's Avatar
    javastuden is offline Senior Member
    Join Date
    Nov 2009
    Posts
    162
    Rep Power
    5

    Default how to create log of sample2010-05-06.log

    Hi
    i'm new in log4j how can i make a log with this formate
    sample2010-05-06.log means the date is attached to the log fle log has to come
    the log file is creating with the property file method
    please help me

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Then you need a time based appender e.g
    Java Code:
      <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
          <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
          <param name="File" value="${jboss.server.log.dir}/server.log"/>
          <param name="Append" value="true"/>
          <!-- In AS 5.0.x the server log threshold was set by a system
               property. In 5.1 and later we are instead using the system
               property to set the priority on the root logger (see <root/> below)
          <param name="Threshold" value="${jboss.server.log.threshold}"/>
          -->
          
          <!-- Rollover at midnight each day -->
          <param name="DatePattern" value="'.'yyyy-MM-dd"/>
    
          <!-- Rollover at the top of each hour
          <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
          -->
    
          <layout class="org.apache.log4j.PatternLayout">
             <!-- The default pattern: Date Priority [Category] (Thread) Message\n -->
             <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
    
             <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
             <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
              -->
          </layout>
       </appender>
    Read the log4j documentation for details.

  3. #3
    javastuden's Avatar
    javastuden is offline Senior Member
    Join Date
    Nov 2009
    Posts
    162
    Rep Power
    5

    Default

    thank you for the help
    but by this it will create 2 log file with sample.log and sample.log.2010-05-06
    and the second one be empty
    what the problem
    my property file is

    #formater
    log4j.appender.DFA=org.apache.log4j.DailyRollingFi leAppender
    log4j.appender.DFA.File=./sample23.log
    log4j.appender.DFA.DatePattern = '.'yyyy-MM-dd-HH-mm-SS
    log4j.appender.DFA.layout=org.apache.log4j.Pattern Layout
    #log4j.appender.DFA.layout.ConversionPattern= %d%-4r [%t] %-5p %c %x - %m%n
    log4j.appender.DFA.layout.ConversionPattern= %d %-5p [%c] (%t) %m%n

Similar Threads

  1. How to create the Jvm using JDK?
    By Sungron in forum New To Java
    Replies: 4
    Last Post: 02-01-2010, 11:50 AM
  2. Create .jar file
    By cestmoiwikies in forum New To Java
    Replies: 2
    Last Post: 09-06-2009, 09:16 AM
  3. How to create animation
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-21-2008, 09:43 PM
  4. Create Calander
    By cheecoo in forum Java Applets
    Replies: 5
    Last Post: 06-12-2008, 04:50 AM
  5. Create XML From XSD
    By Jack in forum XML
    Replies: 1
    Last Post: 07-09-2007, 01:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •