File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes error in log4j.properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "error in log4j.properties" Watch "error in log4j.properties" New topic
Author

error in log4j.properties

sulthan mathina
Greenhorn

Joined: Jan 31, 2011
Posts: 6
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.
sri ramvaithiyanathan
Ranch Hand

Joined: Nov 20, 2010
Posts: 109
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

For java examples,ebooks,interview questions,visit this blog
http://periodicupdates.blogspot.com/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error in log4j.properties
 
Similar Threads
log4j does not works because it says there is no appender
log4j:WARN No appenders could be found for logger (log4jexample.LogExample).
Need help with log4j logging tool to log into database
log4j:WARN Please initialize the log4j system properly
what is log4j.properties , why we need this. how to create this in java project using eclipse IDE