• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

log4j - no output to .log file

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The level for the root appender looks incorrect. You have set it to "off". Change it to "DEBUG" and see if it works.
 
reply
    Bookmark Topic Watch Topic
  • New Topic