Log4J


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Log4J

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    London
    Posts
    10

    Log4J

    Hope someone may know this as it seems to be a fairly common question on the internet but I have been unable to find the answer I am looking for - I have used Log4j in the past and have always managed to work with it but I am now using it with OpenAdapter.

    error=
    log4j: No appenders could be found for category (some.category.name).
    log4j: Please initialize the log4j system properly.

    the solution to this that I have found is:
    Log4j does not have a default logging target. It is the user's responsibility to ensure that all categories can inherit an appender. This can be easily achieved by attaching an appender to the root category.


    All sounds very easy but how do I attach an appender to the root category - I presume this means tell it where to output the log i.e. to the console but how? Is this through a properties file and if so what are the settings?

    Thanks for your help

    M

  2. #2
    Join Date
    Jan 2005
    Posts
    1
    I am having the same problem.

    here is my properties file:

    log4j.logger.wroxLogging.SampleLogTest=WARN,WroxTestFile
    log4j.appender.WroxTestFile=org.apache.log4j.FileAppender
    log4j.appender.WroxTestFile.File=c:/Tomcat5-5/logs/WroxSampleLog.log
    log4j.appender.WroxTestFile.layout=org.apache.log4j.SimpleLayout



    this is located in c:\Tomcat5-5\conf directory

    my java file is:
    package wroxLogging;
    import org.apache.log4j.Logger;
    import org.apache.log4j.Level;
    import org.apache.log4j.PropertyConfigurator;

    public class WroxTestLog4J{
    static Logger WroxLogger=Logger.getLogger("wroxLogging.SampleLogTest");
    public static void main(String [] args) {

    PropertyConfigurator.configure("SampleLog.properties");

    WroxLogger.debug("TEST" + WroxLogger.getName());

    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center