aspose file tools *
The moose likes Other JSE/JEE APIs and the fly likes Error setting up Logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Error setting up Logging" Watch "Error setting up Logging" New topic
Author

Error setting up Logging

Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
I have an error on the logging on this code snippet. I have not set up log4j. Can someone please direct me to a resource for setting up log4j into a dynamic web project in Eclipse Juno or similar IDE?

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2628
    
    9

You can access log4J v1.2 here and the short intro

Basically download the jar put it in your web app WEB-INF/lib
in your Java code import those libraries and add line similar to


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
Hello:


Thanks a lot! I think I have a handle on this now, however, I need to know the following:

What is the most recent release of Log4J?

I went out and looked around and noticed this: http://logging.apache.org/log4j/2.x/download.html

I would like to download a stable release, not a beta version of the jar.

Thanks,
Michele
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2628
    
    9

The stable version would be v1.2 (link provided earlier).
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
Hello Thank you for the clarification, it was not super clear from looking at the Apache Log4J pages. I did notice the project I inherited had two Log4Js in the lib folder of the web project, one which is log4j-1.2.13 and one which is log4j-1.2.15. I noticed the one you referred me to is log4j-1.2.17. When I removed 13 and 15 and put 17 in, it broke the entire application, referring to DWR.

Direct Web Remoting.

I guess I need to look at the Direct Web Remoting to figure out what is happening there.

In general, however, what is your opinion on having 2 different log4js in the lib folder, the log4j-1.2.13 and the log4j-1.2.15, the project builds with it? The current build I inherited has these two in it. Also, with a web project, does the log4j.properties create an empty folder called Log4J in the Web application? Or, do I need to put an empty folder into the web project for the logs to be archived?


So the content of log4j.properties file would be as follows:
# Define the root logger with appender file
log = /usr/home/log4j
log4j.rootLogger = DEBUG, FILE

Last but certainly not least, you directed me to this page: http://logging.apache.org/log4j/1.2/download.html, and when I went there, I found the .jar 17 but I found a lot of other things as well. In general, what are the basic requirements for using Log4J?

Thanks,
Michele
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2628
    
    9

Hi I don't know why you need 2 log4j jars in your project. The only thing I do know is that the latest log4j uses Java 6 (not sure if this actually applies for v1.2). Older version may be compatible with Java 5 or even 4. Yet I don't seem to find this "what Java version is needed" on the website.

From my experience if indeed 2 jars are present, the newer is used.

FYI DWR default loggin implementation uses Apache commons logging but since it already uses log4j, maybe its the config files.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error setting up Logging