Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

error in log4j.properties

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
log4j.properties
# The following properties set the logging levels and log appender. The
# log4j.rootCategory variable defines the default log level and one or more
# appenders. For the console, use 'S'. For the daily rolling file, use 'R'.
# For an HTML formatted log, use 'H'.

log4j.rootCategory=DEBUG, S,R

log4j.logger.com.bgs.entity=INFO
# The following properties configure the Daily Rolling File appender.
log4j.appender.R = org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File = c:/excel/sm7.log
log4j.appender.R.Append = true
log4j.appender.R.DatePattern = '.'yyy-MM-dd
log4j.appender.R.layout = org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss},[%p],%c{1},%M,%m%n

In java:Main.java

public class Main
{
static Logger logger = Logger.getLogger("Main");

Error in console , while executing java file

log4j:WARN No appenders could be found for logger (Main).
log4j:WARN Please initialize the log4j system properly.
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

sulthan mathina wrote:log4j.properties
log4j.rootCategory=DEBUG, S,R


check whether you commented the above mentioned lines.
and remove the S.your code should be like this

Because you haven't used S in your log4j.properties file.
If you use S you will get the following error

In your java class use this way

instead of static Logger logger = Logger.getLogger("Main");

Regards,
Sriram.V
 
A wop bop a lu bob a womp bam boom. Tutti frutti 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!