• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

log4j not logging

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"/>
</layout>
</appender>

<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"/>
</layout>
</appender>

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


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

</log4j:configuration>


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?


Eric
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you've taken care of everything servlet specific in your last post
https://coderanch.com/t/365514/Servlets/java/initializing-log

So..
I'm going to move this to our Other Open Source Projects forum where Log4j is usually covered.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the code where you initialize the logger and also the piece of code where you are logging the messages?
 
John Eric Hamacher
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved my problem. My log4j.xml wasn't named log4j.xml!
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!