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



Home Answers Viewqa Log4J L4j in WebApplication with common logging

Have Programming Question? Ask it here!
 
 
 


shyam
L4j in WebApplication with common logging
3 Answer(s)      6 years and 6 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
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
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
Logging Tutorial - Part 1
Logging Tutorial - Part 1 2000-12-14 The Java Specialists' Newsletter [Issue 003] - Logging part 1 Author: Dr. Heinz M. Kabutz If you are reading... information. Logging Part 1 of ... (haven't decided yet ;-) While we
Logging part 2
Logging part 2 2001-01-11 The Java Specialists' Newsletter [Issue 004] - Logging part 2 Author: Dr. Heinz M. Kabutz If you are reading... up winning a free lunch :] Logging Part 2 of ... (still cannot decide
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
The common tasks of JDBC.
The common tasks of JDBC.  What are the common tasks of JDBC
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
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
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
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
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
How to solve the Hibernate Common Exceptions?
How to solve the Hibernate Common Exceptions?  How to solve the Hibernate Common Exceptions
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
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
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
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
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
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
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
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
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
Five common Ajax patterns
Five common Ajax patterns         First published by IBM developerWorks at http... Perhaps the most common Ajax task is to request updated HTML from
some queries pertaining to use of log4j for logging in a java application-
some queries pertaining to use of log4j for logging in a java application-  Please clarify the following for me- (1) I want to use a rollingfile appender, that too in such a way that the actual log file (to which log4j should
Common Component Methods
Common Component Methods       The common methods of AWT components are as follow: 1 getLocation() - This method is used to get position of the component, as a Point
common Menu bar(toolBar) at the top of all view
common Menu bar(toolBar) at the top of all view  I creat on login page and after sign in I move to next page. Now I want to add menu bar at the top of my all view. Any one have any idea abt how to do
JSP- common dbase connection - JSP-Servlet
JSP- common dbase connection  Hi! Thanks for your suggession regarding Live news... Now it is working.... I have a small doubt in dbase connection.... I want to write only one dbase connection and i want to call
Some Common Types of FTP Commands
it is important to know some common types of FTP commands. Though, many FTP.... To start with the most common basic FTP commands let us first know some... stands for local filename rfilename stands for remote filename Some common
How to make the horizontal navigation bar common to all pages?
How to make the horizontal navigation bar common to all pages?  Hi... the navigation bar common to all the jsp pages. I have a header, and navigation bar and want to make the navigation bar and header common to all the pages. Thanks
pls provide common path to set image in flex - XML
pls provide common path to set image in flex  hi, pls provide common setpath to image in flex.when i give ful path like these C:\eclipse\workspace... the coding in mxml to set common path of image in flex
common database jsp file for all the jsp files in the application
common database jsp file for all the jsp files in the application  hi, i have written jspcode to connect to mysqldatabase . i need the code to make use of this single jsp file while connecting to database rather than writing
Display Common Elements from two ArrayLists in Java
Display Common Elements from two ArrayLists in Java In this section, we are going to compare two array lists and display the common elements from both of them. To show the common elements from the two list, we have created two array
10 Common Web Design Mistakes
10 Common Web Design Mistakes Designing a website is the most crucial part... discussion on top 10 common web design mistakes we must understand the effectiveness... mould as they have been in earlier time. Some of the most common web design
Use of BasicConfigurator in Log4j logging
Use of BasicConfigurator in Log4j logging  ... of program to the logging request. "Hello world" is the message that we have... who have invoked logging. Download Source Code   
Common Interview Questions
Common Interview Questions     ... research on the company, it will better to prepare answer to some common interview... this will boost your confidence in any interview.  Common Interview
SmartInspect
; SmartInspect is an advanced .NET logging, Java logging and Delphi logging tool for debugging and monitoring your projects and applications... you to analyze your logging information and enables you to monitor your
Apache Log4J is the leading logging framework in Java.
Apache Log4J is the leading logging framework - User Apache Log4J for unit testing of your code. As we know, logging is an important part for any software development exercise and it is well written logging code, which provides
Advertisements
 

 

 

DMCA.com