L4j in WebApplication with common logging

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 Apache common

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









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
ru.tinkoff.kora - logging-common version 0.11.2 Maven dependency. How to use logging-common version 0.11.2 in pom.xml?
ru.tinkoff.kora  - Version 0.11.2 of logging-common Maven dependency? How to use  ru.tinkoff.kora  - Version 0.11.2 of logging-common in pom.xml? How to use logging-common version 0.11.2 in pom.xml? Learn to use
Maven Repository/Dependency: ru.tinkoff.kora | logging-common
Maven Repository/Dependency of Group ID ru.tinkoff.kora and Artifact ID logging-common. Latest version of ru.tinkoff.kora:logging-common dependencies. # Version Release Date 1
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
Maven dependency for ru.tinkoff.kora - logging-common version 0.13.2 is released. Learn to use logging-common version 0.13.2 in Maven based Java projects
-common released The developers of   ru.tinkoff.kora - logging-common..., the released version of  ru.tinkoff.kora - logging-common library is 0.13.2. Developer can use this version ( ru.tinkoff.kora - logging-common version
Maven dependency for ru.tinkoff.kora - logging-common version 0.11.10 is released. Learn to use logging-common version 0.11.10 in Maven based Java projects
-common released The developers of   ru.tinkoff.kora - logging..., the released version of  ru.tinkoff.kora - logging-common library is 0.11.10. Developer can use this version ( ru.tinkoff.kora - logging-common version
jsp webapplication
Maven dependency for pl.allegro.tech.hermes - hermes-common version 1.8.6-batch-exceptions-logging is released. Learn to use hermes-common version 1.8.6-batch-exceptions-logging in Maven based Java projects
-exceptions-logging of hermes-common released The developers of  ...; pl.allegro.tech.hermes - hermes-common library is 1.8.6-batch-exceptions-logging. Developer can use...-exceptions-logging in project? Steps to use  pl.allegro.tech.hermes - hermes-common
Maven dependency for pl.allegro.tech.hermes - hermes-common version 1.8.6-batch-exceptions-logging is released. Learn to use hermes-common version 1.8.6-batch-exceptions-logging in Maven based Java projects
-exceptions-logging of hermes-common released The developers of  ...; pl.allegro.tech.hermes - hermes-common library is 1.8.6-batch-exceptions-logging. Developer can use...-exceptions-logging in project? Steps to use  pl.allegro.tech.hermes - hermes-common
Version of commons-logging>commons-logging dependency
List of Version of commons-logging>commons-logging dependency
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 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
ModuleNotFoundError: No module named 'logging'
ModuleNotFoundError: No module named 'logging'  Hi, My Python... 'logging' How to remove the ModuleNotFoundError: No module named 'logging... to install padas library. You can install logging python with following command
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
Why servlet in WebApplication - Servlet Interview Questions
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
ModuleNotFoundError: No module named 'aws-logging-aws-logging-handlers'
ModuleNotFoundError: No module named 'aws-logging-aws-logging-handlers' ...: ModuleNotFoundError: No module named 'aws-logging-aws-logging-handlers' How to remove the ModuleNotFoundError: No module named 'aws-logging-aws-logging-handlers'
ModuleNotFoundError: No module named 'aws-logging-aws-logging-handlers'
ModuleNotFoundError: No module named 'aws-logging-aws-logging-handlers' ...: ModuleNotFoundError: No module named 'aws-logging-aws-logging-handlers' How to remove the ModuleNotFoundError: No module named 'aws-logging-aws-logging-handlers'
Maven Repository/Dependency: commons-logging | commons-logging
Maven Repository/Dependency of Group ID commons-logging and Artifact ID commons-logging. Latest version of commons-logging:commons-logging dependencies. # Version Release Date 1
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.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.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.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
Version of tomcat>commons-logging dependency
List of Version of tomcat>commons-logging dependency
Version of com.nitorcreations>willow-logging dependency
List of Version of com.nitorcreations>willow-logging dependency
Version of com.sdklite>sphere-logging dependency
List of Version of com.sdklite>sphere-logging dependency
Version of plexus>plexus-logging dependency
List of Version of plexus>plexus-logging dependency
Version of com.logscale>logscale-logging dependency
List of Version of com.logscale>logscale-logging dependency
Version of com.shedhack>shedhack-logging dependency
List of Version of com.shedhack>shedhack-logging dependency
ModuleNotFoundError: No module named 'argparse-logging'
ModuleNotFoundError: No module named 'argparse-logging'  Hi, My... named 'argparse-logging' How to remove the ModuleNotFoundError: No module named 'argparse-logging' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'cloudshell-logging'
ModuleNotFoundError: No module named 'cloudshell-logging'  Hi, My... named 'cloudshell-logging' How to remove the ModuleNotFoundError: No module named 'cloudshell-logging' error? Thanks   Hi, In your

Ads