Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Log4J L4j in WebApplication with common logging
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shyam
L4j in WebApplication with common logging
3 Answer(s)      6 years and 11 months 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


Advertisement
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
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
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
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
Logging in JMeter - JUNIT
Logging in JMeter  I am using JMeter to execute JUnit test cases. I want the logs from the test case class alone to be logged in a separate log file. What are the modifications need to be done in jmeter.properties to achieve
remove logging - Log4J
remove logging  How to remove the logging from crystal reports only? log4j hss been used for logging purpose.Thanks and regards vishal  hi friend,Crystal Reports XI is the definitive ?out of the box&#65533
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
The common tasks of JDBC.
The common tasks of JDBC.  What are the common tasks of JDBC
Boneclipse-logging
Boneclipse-logging This was my very first Eclipse plugin... add error or debug logging statements. At this point in time, it is Log4J...://www.bonevich.com/boneclipse-master/boneclipse-logging
Hibernate Logging using Log4j
This section contains detail description of how you can use Log4j for logging configuration
Logging Filter Servlet Example
Logging Filter Servlet Example       Example program to demonstrate Logging Filter This example illustrates how one can write Logging Filter servlet to provide
Web Application Common Architecture
Web Application Common Architecture  Hi, Any one tell me, while project constructing , how they architect it which means using some layers and specify importance of layers. And also best way to follow program flow
log4j is not logging even under src path
log4j is not logging even under src path  We are working with struts application and using log4j.properties file , it is placed under WEB-INF/classes... this it is not logging messages in linux servers . It is working in local setup. Please
What is Logging Level?
What is Logging Level?      ... the Object class. Java provides logging APIs like: Logger, Level, Handler etc. for implementing logging features in your java application.  It is a part
How to solve the Hibernate Common Exceptions?
How to solve the Hibernate Common Exceptions?  How to solve the Hibernate Common Exceptions
Logging inside HTTP and HTTPS site using J2EE
Logging inside HTTP and HTTPS site using J2EE  How to login inside a site like gmail or yahoo mail using a servlet(username and password present in the servlet itself) that leads directly into my inbox page
Logging and Determining a Logged Message
Logging and Determining a Logged Message       This section introduce you about Java logging and how.... Explanation of java logging is explained in the given example program
java list program for common elements
java list program for common elements  hi I want program using java collections list which takes two array list elements and display common...: Display Common Elements from two ArrayLists
JDBC Logging Example
; } JDBC Logging Example JDBC Logging JDBC logging feature initially..., expandable logs in your application. With JDBC logging API you can create your ... Another Example for JDBC File Logging LoggingJDBCExample.java package
how to disable back button of a browser after logging in? - JSP-Servlet
how to disable back button of a browser after logging in?  how to disable back button of a browser after logging in?  where is the source code
Common connection in JSP - JSP-Servlet
Common connection in JSP  Hi I am creating an JSP application. I want to use a common JSP page so that I can include it into other pages and get connection to database. I am able to get connection in other(common) JSP
Logging an Exception in Java
Logging an Exception in Java       This section introduces you the concept of logging exception handling. When certain conditions are not followed or wrong then compiler shows
Most Common TCP Ports
Ports are basically divided into three ranges: the Common Ports, the Registered Ports, and Private Ports. The Common Ports are those from 0 through 1023... are those from 49152 through 65535 Common Ports The Common Ports are assigned
What are the most common methods of Hibernate configuration?
What are the most common methods of Hibernate configuration?  Hi, What are the most common methods of Hibernate configuration? thanks
identify admin from user when logging in - Java Beginners
identify admin from user when logging in  hi everyone... and password were requested for a user to log-in, but there are 2 kinds of user types(admin and user).and the usertype are also saved in the database. my question is,how
Java Logs
Java Logs       Logging is the most common concern to keep in mind by the development teams. In java logging is achieved through a logger class which provides an object allowing
Advertisements
 

 

 

DMCA.com