You have 2 unrelated issues
- log4j needs configuration file - log4j properties or log4j.xml.
- you have an error in your namer.xml or (less likely but possible) you use quite outdated SAX parser. Which JDK are you using? Do you have some XML-related libraries on your classpath (that did not came with JDK)?
For the 1st problem just put log4j.properties in your classpath with following contents
Code:
log4j.rootLogger=debug, console,rollingFiler
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.SimpleLayout
log4j.appender.console.Threshold=INFO
log4j.appender.rollingFiler=org.apache.log4j.RollingFileAppender
log4j.appender.rollingFiler.File=namer.log
log4j.appender.rollingFiler.MaxFileSize=5MB
log4j.appender.rollingFiler.MaxBackupIndex=3
log4j.appender.rollingFiler.layout=org.apache.log4j.PatternLayout
log4j.appender.rollingFiler.layout.ConversionPattern=%-7p %d{ISO8601} %c{2} - %m%n
Then you may read log4j documentation and refine the contents according to your needs.
If your application is web one, then you may want take a look on javadoc for org.springframework.web.util.Log4jConfigListener (and related classes).
Concerning 2nd probleim nothing is possible to say without looking on your XML. Just post it here (do not forget CODE tags!).

Originally Posted by
ahmadgee
Thanks for providing me a solution and special for tip. But I am getting now the following error. While I have inlcluded the log4j liberary And also provided the bean defintion and you can check please where is the mistake?
log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionSt oreException: Line 6 in XML document from file [e:\Dokumente und Einstellungen\praktikum\workspace\simplespring\src \resources\namer.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl$NSContentDispatcher.scanRootElement Hook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDispatcher.dis patch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:357)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:308)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:283)
at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:61)
at examples.SimpleSpringApp.main(SimpleSpringApp.java :12)