jQuery in Action, 3rd edition
The moose likes Other Open Source Projects and the fly likes log4j not logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j not logging" Watch "log4j not logging" New topic

log4j not logging

John Eric Hamacher
Ranch Hand

Joined: Apr 25, 2007
Posts: 230
I have just successfully gotten a log4j XML configuration to load.

Here is the configuration:

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="c:\log\A3.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="500KB"/>
<param name="MaxBackupIndex" value="1"/>
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} - [%C.%M] - %p - %m%n"/>

<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="DEBUG"/>

<layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>

<category name="com.enetrix.sis">
<priority value="INFO"/>
<appender-ref ref="FILE"/>
<appender-ref ref="CONSOLE"/>

<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>


where com.enetrix.sis is a parent package to several other packages. Notice that I'm logging to both a category and the root logger.

I get no output neither console or file. It isn't my Java, I've used log4j for years. Any suggestions?

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

It looks like you've taken care of everything servlet specific in your last post

I'm going to move this to our Other Open Source Projects forum where Log4j is usually covered.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

Can you post the code where you initialize the logger and also the piece of code where you are logging the messages?

[My Blog] [JavaRanch Journal]
John Eric Hamacher
Ranch Hand

Joined: Apr 25, 2007
Posts: 230
Solved my problem. My log4j.xml wasn't named log4j.xml!
I agree. Here's the link: http://aspose.com/file-tools
subject: log4j not logging
It's not a secret anymore!