log4j

How can I provide a custom log4j.xml for different ant tasks?

I have a build file that as part of the build process relies on several taskdefs. These taskdef items (for example, webdoclet and jasper2) use log4j as a logger. Ideally, I'd like to be able to provide a different log4j configuration file for each, but minimally, I'd like to be able to specify which log4j configuration file is used. W...

override level of subcategory in log4j configuration

There is some auditing in my application. Every audit event has it's own log4j category with name that is prefixed by same string. EG: general auditing category name: com.company.audit web login category name: com.company.audit.web.login create something: com.company.audit.api.create etc.. some of the categories should be logged by de...

Doubt in FileAppender in log4j API

Hi All, I have created java program which will process different file which coming to the particular folder.In my program, I need to create log file for each incoming file for logging exception for that file. I have used the below code for that. Problem i am facing is for 1st file it creates log file and logging exception. When second f...

3rd party jars creating log files

So we ran into an interesting issue today. We have a JEE (J2EE) web app that uses a bunch of 3rd party jars. This includes Hibernate. We use the java logging api that comes with the SDK for logging purposes. Typically we are pretty thin on logging but we ran into this issue with one of our 3rd party jars using log4j to create it's own l...

Using external log4j.properties file with Grails

What's the best way to use an external log4j.properties file within Grails? I'd like to use the traditional log4j.properties format rather than a log4j.groovy style configuration. I'm also curious if the external configuration will play nicely with the log4j.properties file that's created by grails war and put into the war file. If I re...

Facing problem in log4j error log and exception handling

Hi : I have used log4j for looging error log using FileAppender. The problem is its logging the same error two times in a log file when the below situation Case1: Class1 : public void func(){ try{ new Class2.prop() }catch(IOException ioe){ logger.log(2,ioe); } } Class2 : public void prop(){ try{ ...

How to direct hibernate logger statements in different log files for differnet applications using jboss-log4j.xml file

Hi, I am using JBOSS 4.2.2 server to deploy multiple web applications. Each application uses Hibernate and for each application there are saperate log files and saparate appendar. Now for Hibernate logging statements of one application should go in log file of that particular application. Does anybody has idea how to configure log4j.xml ...

Is there a log4j or commons logging extension or other logging framework that is designed for Java 5 or higher?

Java 5 has introduced many features that can be make logging statements less cluttering, such as variable number of arguments and printf. That can alleviate all the message building code that happens when something is logged, as well as the surrounding if. For example, instead of writing: if (log.isDebugEnabled() { log.debug("User ...

Log4J - Is there any point in explicitly specifying the class name in the call to LogManager.getLogger()?

I'm working on some legacy code with a lot of code like private final Logger logger = LogManager.getLogger(ThisClassName.class); I'm wondering if there is any advantage to typing out "ThisClassName.class" as opposed to LogManager.getLogger(getClass()); As far as I can tell, there is none, but I'm wondering if there are any negative...

In log4j, is there a way to log errors based on timestamp?

log4j is logging errors based on level. Is there a way to log errors based on timestamp? ...

Log4J timestamp

Hi, Looks like timestamp is not in sequence, means logging based on level.Can We display based on timestamp? 2009-02-19 14:47:01,288 DEBUG [com.catalystwms.core.persistence.TransactionContext] 2009-02-19 14:54:27,429 INFO [com.catalystwms.tms.services.background.purge.PurgeManager] 2009-02-19 14:47:01,288 DEBUG [com.catalystwms.core...

log4j output suppressed?

I'm brand new with log4j and I can't seem to figure this out. If I set log4j.configuration to some garbage file that doesn't exist, the following program works as I expect. But if I don't then it's silent (other than printing out the properties): package com.example.test; import org.apache.log4j.*; public class Log4jExample2 { fin...

Disabling Log4J Output in Java

How can one quickly turn off all Log4J output using a log4j.properties file? ...

Using log4j logging in weblogic 9/10

In weblogic I can configure in the console for the Serverlog to use log4j instead of default JDK logging. However the serverlog is not using a log4j.properties file, but seems to use the configuration in config.xml Even if the log4j.properties file is in the classpath and I set these properties: set JAVA_OPTIONS=%JAVA_OPTIONS% -Dlog4j....

java.util.logging.Logger and log4j

I am trying to compile the code from here: http://www.brackeen.com/javagamebook/#download (Chapter 6) and am having trouble. I don't understand how java.util.logging.Logger and log4j work together, but that seems to be the issue. The errors I get are all on the log.error() or log.warn() method calls. Here is the output from NetBeans: ...

log4j extra logging arguments

I'm developing a (internal) library where I want to enforce that developers using this lihrary include a text ID when logging error or fatal level messages. Without modifying log4j, what we want to enforce is similar to: logger.error( "E1234:An error has occured" ); With none or minor extension to log4j we could either, during nightly ...

Why are my Log4j log file timestamps out of order, and how do I fix it?

My log4j.xml contains: <appender class="org.jboss.logging.appender.RollingFileAppender" name="rm"> ... </layout> My log file shows timestamps that are out of order. Can we display based on timestamp? 2009-02-19 14:47:01,288 DEBUG [com.catalystwms.core.persistence.TransactionContext] 2009-02-19 14:54:27,429 INFO [com.catalystw...

Logging Java web applications?

I am planning to implement logging into a web application that I am currently working on but I am struggling with some of the details. What is the best way to go about logging a Java web application? Specifically; Where does the configuration file go in .war package file? Where do people log to, relative or absolute path flat file, o...

repeated logging in log 4j in java

I used log4j in a java program. I initialized it with : BasicConfigurator.configure(); // logger configuration try { logger.setLevel(Level.DEBUG); } catch (Exception e) { System.out.println("Logfile not found"); } But, during the execution of the program i get 3 log statements instead of one. For example, 3 lines 1047 [mai...

Log4j is hanging my application what am I doing wrong?

First some background on the application. I have an application processing many independent tasks in parallel via a thread pool. The thread pool is now hanging. The following is an snippet from my thread dumps, all my Threads in pool-2 are BLOCKED by "pool-2-thread-78". It seems to be locked trying to write to the console which I find e...