File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes log4j - no output to .log file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j - no output to .log file" Watch "log4j - no output to .log file" New topic
Author

log4j - no output to .log file

Jenny Kim
Greenhorn

Joined: May 28, 2008
Posts: 6
Hi, I'm having some problems with getting my debug messages from my classes to output to a .log file. Here's my log4j.xml configuration file so far:

....
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MMM dd yyyy HH:mm:ss,SSS} %-5p %c - %m%n"/>
</layout>
</appender>
<appender name="logFile" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="myLog.log" />
<param name="Append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MMM dd yyyy HH:mm:ss,SSS} %t %-5p %c{2} - %m%n"/>
</layout>
</appender>
<logger name="com.myCompany.myPackage">
<level value="debug"/>
<appender-ref ref="logFile"/>
<appender-ref ref="console"/>
</logger>
<root>
<level value="off"/>
<appender-ref ref="logFile"/>
</root>
</log4j:configuration>

As you can see, I've got messages from my package outputting to both the "logFile" and "console" appenders.

The "console" appender outputs the messages I've put into my class sucessfully, e.g:
Sep 11 2008 07:21:51,102 DEBUG com.myCompany.myPackage.MyClass - ***TEST*** This is a debug message

But this line doesn't seem to be going out to myLog.log . I've only got a bunch httpclient and wire messages in it:

....
Sep 11 2008 07:19:00,873 main DEBUG wire.content - << "[\n]"
Sep 11 2008 07:19:00,873 main DEBUG wire.header - << "[\r][\n]"
Sep 11 2008 07:19:00,874 main DEBUG httpclient.HttpMethodBase - Resorting to protocol version default close connection policy
Sep 11 2008 07:19:00,874 main DEBUG httpclient.HttpMethodBase - Should NOT close connection, using HTTP/1.1
...

...there's nothing from my own classes.

Is there an extra configuration I'm missing somewhere?

BTW, I don't know if this will help but I'm deploying this app as a .war to a GlassFish server.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10069
    
163



The level for the root appender looks incorrect. You have set it to "off". Change it to "DEBUG" and see if it works.


[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j - no output to .log file