L4j in WebApplication with common logging

Ads

 
 

Share on Google+Share on Google+

shyam
L4j in WebApplication with common logging
3 Answer(s)      9 years ago
Posted in : Log4J

Hi, I want to configure log4j for Web Application in which common logging api used i tried to configure... Property Configure code to add appender i think not because we are using Apache common

Ads
View Answers

February 24, 2008 at 11:39 PM


Hello,

Please check the answer at http://www.roseindia.net/answers/viewanswers/173.html

Thanks


February 26, 2008 at 10:58 AM


Thank you for quick response but it is not working.


i am writting follwing code to cinfigure my log4j in my servlet inside static block
PropertyConfigurator.configure("log4j.properties");

and access loger by the following code
private org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass());

i have got the following error :
log4j:ERROR Could not instantiate class [org.apache.log4j.ConsoleAppe nder].
java.lang.ClassNotFoundException: org.apache.log4j.ConsoleAppe nder
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1498)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:179)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:320)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:121)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:664)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:544)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:440)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:476)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:125)
at org.apache.log4j.Logger.getLogger(Logger.java:105)
at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:283)
at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:108)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1040)
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:838)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:601)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:333)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:307)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645)
at com.synapticresearch.framework.servlet.DispatcherServlet.<init>(DispatcherServlet.java:23)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1132)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:832)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
log4j:ERROR Could not instantiate appender named "stdout".
log4j:ERROR Could not read configuration file [log4j.properties].
java.io.FileNotFoundException: log4j.properties (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:316)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:342)
at com.synapticresearch.backofficeapp.controller.LoginController.<clinit>(LoginController.java:33)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at com.synapticresearch.framework.servlet.DispatcherServlet.processRequest(DispatcherServlet.java:61)
at com.synapticresearch.framework.servlet.DispatcherServlet.service(DispatcherServlet.java:116)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
log4j:ERROR Ignoring configuration file [log4j.properties].

Thank you


October 30, 2010 at 5:14 PM


Hi,

In your program log4j.properties file is missing.

java.io.FileNotFoundException: log4j.properties (The system cannot find the file specified)

Create a new file log4j.properties in src directory and add the following content:

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout

Thanks


Ads









Related Tutorials/Questions & Answers:
L4j in WebApplication with common logging - Log4J
L4j in WebApplication with common logging   Hi, I want to configure log4j for Web Application in which common logging api used i tried to configure... Property Configure code to add appender i think not because we are using
L4j in WebApplication with common logging - Log4J
project.So create log4j.properties file with following content:# Default Logging Configuration log4j.rootLogger=INFO, stdout#to increase logging level#log4j.logger.org.dcm4cheri=DEBUG #to decrease logging level #log4j.logger.org.dcm4cheri=ERROR
Advertisements
Webapplication Security - Security
Webapplication Security  Hello, Experts how i can i prevent a user cannot copy url from a webapplication
how to test the strtus webapplication on myeclipse6.0 - CVS
how to test the strtus webapplication on myeclipse6.0  I am using the myeclipse6.0 now,how to test the webapplication on myeclipse and how to use checkin and check out
Sample Code for DTO in WebApplication - Development process
Sample Code for DTO in WebApplication   Hi Friends, Can u explain DTO in webapplication with sample code
Why servlet in WebApplication - Servlet Interview Questions
Why servlet in WebApplication  Hi Frieds, I am new to servlet why to use servlet in webapplication. what i know is " use servlet as a controller in mvc and to implemnent business logic . is it correct ? One more thing
logging in java
logging in java  Hi, Im using loggers in standalone java program.i need to store the loggers in a xxx.log file in classpath.how can i implement this using slf4j loggers or anythig else
Version of commons-logging>commons-logging dependency
List of Version of commons-logging>commons-logging dependency
Version of avalon-logging>avalon-logging-api dependency
List of Version of avalon-logging>avalon-logging-api dependency
Version of avalon-logging>avalon-logging-impl dependency
List of Version of avalon-logging>avalon-logging-impl dependency
Version of avalon-logging>avalon-logging-spi dependency
List of Version of avalon-logging>avalon-logging-spi dependency
Version of commons-logging>commons-logging-api dependency
List of Version of commons-logging>commons-logging-api dependency
Maven Dependency commons-logging >> ${commons_logging_version}
You should include the dependency code given in this page to add Maven Dependency of commons-logging >> commons-logging version${commons_logging_version} in your project
Version of avalon-logging>avalon-logging-logkit-api dependency
List of Version of avalon-logging>avalon-logging-logkit-api dependency
Version of avalon-logging>avalon-logging-logkit-datagram dependency
List of Version of avalon-logging>avalon-logging-logkit-datagram dependency
Version of avalon-logging>avalon-logging-logkit-impl dependency
List of Version of avalon-logging>avalon-logging-logkit-impl dependency
Version of avalon-logging>avalon-logging-logkit-socket dependency
List of Version of avalon-logging>avalon-logging-logkit-socket dependency
Version of avalon-logging>avalon-logging-logkit-syslog dependency
List of Version of avalon-logging>avalon-logging-logkit-syslog dependency
Version of com.godaddy>logging dependency
List of Version of com.godaddy>logging dependency
Version of com.spotify>logging dependency
List of Version of com.spotify>logging dependency
Version of com.tiscover>logging dependency
List of Version of com.tiscover>logging dependency
Artifacts of avalon-logging
List of Artifacts of avalon-logging maven depenency
Artifacts of commons-logging
List of Artifacts of commons-logging maven depenency
Hibernate Logging using Logback Logging Framework
In this section, you will learn how to configure logging using Logback Logging Framework. Logback is purposefully created to be successor of the Log4j
Maven Dependency commons-logging >> 1.0
You should include the dependency code given in this page to add Maven Dependency of commons-logging >> commons-logging version1.0 in your project
Maven Dependency commons-logging >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of commons-logging >> commons-logging version1.0.1 in your project
Maven Dependency commons-logging >> 1.0.2
You should include the dependency code given in this page to add Maven Dependency of commons-logging >> commons-logging version1.0.2 in your project
Maven Dependency commons-logging >> 1.0.3
You should include the dependency code given in this page to add Maven Dependency of commons-logging >> commons-logging version1.0.3 in your project
Maven Dependency commons-logging >> 1.0.4
You should include the dependency code given in this page to add Maven Dependency of commons-logging >> commons-logging version1.0.4 in your project
Maven Dependency commons-logging >> 1.1
You should include the dependency code given in this page to add Maven Dependency of commons-logging >> commons-logging version1.1 in your project

Ads

 
Advertisement null

Ads