• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Problem in Log4j

 
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,

I have the following log4j.properties file:

log4j.logger.com.test=INFO,log
log4j.appender.log=org.apache.log4j.DailyRollingFileAppender
log4j.appender.log.File=C:/Test.log
log4j.appender.log.DatePattern='.'yyyy-MM-dd
log4j.appender.log.Append=true
log4j.appender.log.layout=org.apache.log4j.PatternLayout
log4j.appender.log.layout.ConversionPattern=%-d %X [%c{2}:%L] %-5p: %m%n %x %n

and i wrote a sample code :


The log file name i need is Test.log_yyyy-MM-dd. But its generating only file name with Test.log

Kindly provide your help. I need the current date to be appended in the log file name. Please point out my mistakes if any.

Thanks & Regards,
Vijay
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name of the currently active file is determined by the log4j.appender.log.File pattern. It will be renamed to include the date pattern after it's been rolled over.
 
We begin by testing your absorbancy by exposing you to this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!