Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-18-2008, 07:24 AM
Member
 
Join Date: Jan 2008
Posts: 3
swapna_d is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-18-2008, 07:42 AM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 249
roots is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-18-2008, 02:25 PM
Member
 
Join Date: Jan 2008
Posts: 3
swapna_d is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-18-2008, 08:49 PM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 249
roots is on a distinguished road
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,
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
Sample Java code for the test
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); }
Output

http://www.java-forums.org/attachmen...1&d=1200681977
Attached Images
File Type: jpg ScreenShot028.jpg (51.5 KB, 2 views)
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-21-2008, 09:12 AM
Member
 
Join Date: Jan 2008
Posts: 3
swapna_d is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-21-2008, 09:49 AM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 249
roots is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding Log4j sidiq New To Java 0 04-07-2008 08:35 PM
log4j with Applet sunjavaboy Java Applets 0 03-25-2008 01:13 AM
Log4j chakri New To Java 1 02-08-2008 11:15 PM
Help log4j SysLogAppender arthik_babu New To Java 0 11-19-2007 02:51 PM
Problems using log4j fred Advanced Java 1 08-06-2007 04:30 AM


All times are GMT +3. The time now is 10:33 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org