Results 1 to 4 of 4
  1. #1
    Virkant Pawar is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default Log4j - setting up name of log file

    Hi,
    I want to name the log file as lod-30-May-04:59.log ( where date and time should change as per the log )
    I searched it but i couldn't find can anybody help me

  2. #2
    chaster is offline Member
    Join Date
    Mar 2008
    Posts
    6
    Rep Power
    0

    Default

    Hello,
    The problem is, that a filename cannot contain several characters (including ':').
    I don't really understand what is your issue... Anyway, here is a piece of code, which kinda does the 'trick' :)
    Java Code:
    import java.util.*;
    import java.io.*;
    
    public class T {
    
    private static void aMethod(String fName)
    {
       Date aDate = new Date();
          try{
    	   BufferedWriter bw = new BufferedWriter(new FileWriter(fName));
    	   bw.close();
               }
               catch (Exception anEx){} // handle filenotfound exception & friends
    }
    
    public static void main(String args[]){
    	String fileName;
    
    	Date aDate = new Date();
    	fileName = aDate.getDate()+"-"
     		     +aDate.getMonth()+"-"
    		         +aDate.getHours()+"."
    		             +aDate.getMinutes()+".log";
    	aMethod(fileName);
    }
    }

  3. #3
    Virkant Pawar is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default

    Hi,
    The code you have given should create file with name i wanted but my questation was how to write a log in that file at run-time.
    any way i got the solution it can be done using org.apache.log4j.DailyRollingFileAppender

  4. #4
    Balamurugan is offline Member
    Join Date
    Jun 2008
    Posts
    1
    Rep Power
    0

    Default How to add mozilla firefox plugin manager?. can u give me any sample code?

    hai

    my problem is, my team leader said, to add plugin manager with mozilla firefox.i don't known this concept. anybody help me with sample code.

Similar Threads

  1. log4j
    By swapna_d in forum New To Java
    Replies: 7
    Last Post: 08-04-2010, 01:23 AM
  2. Regarding Log4j
    By sidiq in forum New To Java
    Replies: 0
    Last Post: 04-07-2008, 08:35 PM
  3. Log4j
    By chakri in forum New To Java
    Replies: 1
    Last Post: 02-08-2008, 11:15 PM
  4. Servlet sending the file (setting header)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-27-2008, 09:14 PM
  5. log4j property file in my application
    By Peter in forum Advanced Java
    Replies: 3
    Last Post: 06-14-2007, 04:12 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
  •