Results 1 to 8 of 8
Thread: log4j
- 01-18-2008, 06:24 AM #1
Member
- Join Date
- Jan 2008
- Posts
- 3
- Rep Power
- 0
log4j
hi
iam new using log4j.properties file to configure log4j
i have used daily rolling file appender to roll the file on daily basis,.........but its not getting rolled at midnight.Iam sending the code which i have used.can u please any suggestions so as to get the output:
sample code used by me
log4j.rootLogger=debug,D
log4j.appender.D=org.apache.log4j.DailyRollingFile Appender
log4j.appender.D.DatePattern='.'yyyy-MM-dd-HH-mm
log4j.appender.D.File=C:/Documents and Settings/user/Desktop/log4j5/DailyRolling.log
log4j.appender.D.layout=org.apache.log4j.PatternLa yout
log4j.appender.D.layout.ConversionPattern=%d{ISO86 01} %-5p [%c] - %m%n
log4j.appender.D.Append =true
- 01-18-2008, 06:42 AM #2
welcome to the forum swapna_d
log4j.appender.D.DatePattern='.'yyyy-MM-dd-HH-mm
causes the log file to be rolled over every minute. Can you try removing HH-mm, I think that should fix the problem.
But if it's not copying your log file every minute than problem might be something else, please write back if this is the case.
DailyRollingFileAppender (Apache Log4j 1.2.15 API)dont worry newbie, we got you covered.
- 01-18-2008, 01:25 PM #3
Member
- Join Date
- Jan 2008
- Posts
- 3
- Rep Power
- 0
thanks for ur reply
the file is not being rolled for every minute(or for hour or for a day)
i have tried out all the possible date formats like '.'yyyy-MM-dd-HH-mm
'.'yyyy-MM-dd-HH and '.'yyyy-MM-dd
but the file is not being created
can u pls give me a solution
- 01-18-2008, 07:49 PM #4
You have some space problem in the code such as space before Appender in second line and space in ISO86 01
Make sure the file for log is accessible, i used a.txt for testing.
This is the fixed code,
Sample Java code for the testJava Code:log4j.rootLogger=debug,D log4j.appender.D=org.apache.log4j.DailyRollingFileAppender log4j.appender.D.DatePattern='.'yyyy-MM-dd-HH-mm log4j.appender.D.File=C:/a.txt log4j.appender.D.layout=org.apache.log4j.PatternLayout log4j.appender.D.layout.ConversionPattern=%d{ISO8601} %-5p [%c] - %m%n log4j.appender.D.Append =true
OutputJava Code:PropertyConfigurator.configure("config.properties"); Logger logger = Logger.getLogger(Main.class); while(true){ // Leaved for 5 minutes to see it happen logger.info("SOME LOG MESSAGE"); Thread.sleep(5000); }
http://www.java-forums.org/attachmen...1&d=1200681977dont worry newbie, we got you covered.
- 01-21-2008, 08:12 AM #5
Member
- Join Date
- Jan 2008
- Posts
- 3
- Rep Power
- 0
log4j
hi
i dont hav any spaces in my code as you mentioned.my code is exactly same as the one which u had sent....but iam not getting.......i need to roll the log file on daily basis
- 01-21-2008, 08:49 AM #6
The config above rolls over the log file every next minute. First thing you need to make sure is that whether Log4J system is properly initialized or not. Atleast you need to see the log file created and rolled over every minute. After that we can simply remove minute and hour arguments to make it to be rolled midnight.
PropertyConfigurator.configure("config.properties" );
This code configures the log4J system. Plus to that make sure that the file name you are giving can be created if necessary.
Please be certain on above two things that log4j is properly initialized and the log4j file is accessable. We can proceed after that.dont worry newbie, we got you covered.
- 08-04-2010, 12:14 AM #7
Member
- Join Date
- Aug 2010
- Posts
- 1
- Rep Power
- 0
Log4j localization problem
Hi,
We have our localization set to a different language using -nl ja (japanese) argument. The problem we are facing with Log4j is that it uses this default JVM locale to print time format's AM/PM in Japanese. We have no clue how to change the Log4j default locale usage.
Is there any Log4j appender property to solve this issue ?
Thanks,
Manoj
- 08-04-2010, 12:23 AM #8
This thread is two and a half years old. If you have a new question you're best to start a new thread.
Similar Threads
-
Regarding Log4j
By sidiq in forum New To JavaReplies: 0Last Post: 04-07-2008, 07:35 PM -
log4j with Applet
By sunjavaboy in forum Java AppletsReplies: 0Last Post: 03-25-2008, 12:13 AM -
Log4j
By chakri in forum New To JavaReplies: 1Last Post: 02-08-2008, 10:15 PM -
Help log4j SysLogAppender
By arthik_babu in forum New To JavaReplies: 0Last Post: 11-19-2007, 01:51 PM -
Problems using log4j
By fred in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 03:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks